Question: How would I code these two Method(reset() & addSuit()) There first picture is of my Deck class of which im having trouble on. heres my

How would I code these two Method(reset() & addSuit())
There first picture is of my Deck class of which im having trouble on.
How would I code these two Method(reset() & addSuit()) There first picture
heres my Card class
is of my Deck class of which im having trouble on. heres

IVAIC FIELUS // ******* Instance data: * cards : ArrayList of Card objects to represent a Deck of cards * MAX SIZE : static final int for size of a deck (Given below) */ // FIXME **** MISSING CODE **** public static final int MAX_SIZE - 52; ArrayList cards = new ArrayList(); 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 // // *** CONSTRUCTOR *** // **** Constructor that calls the reset method to set up the deck */ // FIXME **** MISSING CODE **** public Deck() { cards.reset(); } 28 * 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 // ******** // *** METHODS *** // *************** /** reset : Initializes the cards ArrayList. calls addsuit for each suit creating all ranks for that suit. Add the suits in this order: spades, hearts, diamonds, clubs Example code: addSuit("spades"); */ // FIXME **** MISSING CODE **** public void reset() { * } * addsuit : For all the ranks of cards (2 to 14), add a new Card object to the cards ArrayList. * @param suit : String for the suit of the card. */ 77 FIXME **** MISSING CODE **** public void addSuit(suit) { 50 51 52 Current file: Card.java 4 1 7 You Card Class gets uploaded 2 public class Card 3 private String suit; 5 private int rank; 6 7 public Card(string suit, int rank){ 8 this. suit = suit; 9 this.rank = rank; 10 0 11 12 public boolean equals(Card otherCard) 13 return rankam othercard.getRank(); 14 } 15 16 public int compareTo(Card otherCard){ 17 return rank otherCard.getRank(); 18 } 19 20 public int getRank 21 return rank; 22 } 23 24 public String getsuit(){ 25 return suit; 26 3 27 28 public String tostring() { 29 return rankToString() + " of + suit; 30 } 31 32 public String rankToString 33 if (rank -14) 34 return "Ace"; 35 else if (rank 36 return "Jack"; 37 else if (rank - 12) 38 return "Queen"; 39 else if (rank - 13) 49 return "King": else 42 return"" + rank; 11) AL

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!