Question: EDIT THE Deck.java file and implement the comments below. add 52 cards to sorted linked list. This can be done in a for loop over

EDIT THE Deck.java file and implement the comments below. add 52 cards to sorted linked list. This can be done in a for loop over each suit to create cards 2-14.

Suit.java

public enum Suit {

SPADES,

CLUBS,

HEARTS,

DIAMONDS

}

// Deck.java

public class Deck {

protected SortedLinkedList cards;

public Deck() {

cards = new SortedLinkedList<>();

}

public void shuffle() {

// TODO implement

// write for loop

// 13 cards for each 4 suits

// Iteriate over suit file

// This method needs to make the 52 cards comprising a card deck

// and add them, in random order, to the SortedLinkedList

// The face of the card will be 2-13. The Ace will be 14 for this game

// I have made this easier for you! Cards have a random number

// already associated to them, and a compareTo method in place

// so that they will sort themselves by their random number.

// All you should need to do is make sure you create the right number of cards, and

// add them to the list! They will shuffle themselves thanks to the insertion sort of the

// linked list

}

public Card draw() {

// TODO implement

//

//

// This method should remove a card from the SortedLinkList and return it

return null;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Solutions Step 1 public class Deck protected SortedLinkedList Card cards public Deck cards new Sorte... View full answer

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 Programming Questions!