Question: Step 2 : Implement the methods of the Card class Complete all methods of the Card class as described by the Javadoc comments. The class
Step : Implement the methods of the Card class
Complete all methods of the Card class as described by the Javadoc comments. The class contains both a suit and a rank. A suit is one of the categories into which the cards of a deck are divided. The rank is the relative importance of the card within its suit.
Note that the Card constructor must convert any rank and suit letters to uppercase.
For the equals method, be sure to follow the steps outlined in Lesson If you did not learn how to implement the compareTo method in your prior course, public class Card implements Comparable Card
private String rank;
private String suit;
Constructor for the Card class
@param rank the rank of card from to A
@param suit the suit of card C D H or S
public ardString rank, String suit
this.rank rank;
this. suit suit;
Returns the card's rank
@return rank a rank from low to A high
public String getRank
return rank;
Returns the card's suit
@return C D H or S
public String getSuit
return suit;
Updates the card's rank
@param rank a new rank
public void setRankString rank
Updates the card's suit
@param suit the new suit
public void setSuitString suit
Concatenates rank and suit
@return card rank and suit
@override public String toString
return ;
Overrides the equals method for Card
Compares rank and suit and
follows the equals formula given in
Lesson and also in Joshua Block's text
@param obj another Object to compare for
equality
@return whether obj is a Card and, if so
of equal rank and suit
@Override public boolean equalsObject obj
return false;
Orders two cards first by suit alphabetically
Next by rank. A is considered the high card
Order goes J Q K A
@param card another Card to compare to this Card
@return a negative number if this comes before c
and a positive number if c comes before this
and if this and c are equal according to the above
equals method
@Override public int compareToCard card
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
