Question: Card.java Define a Card class with the following API: public Card(Suit suit, int rank) public int getRank() public Suit getSuit() public String toString() // Ace

Card.java

Define a Card class with the following API:

public Card(Suit suit, int rank)

public int getRank()

public Suit getSuit()

public String toString() // "Ace of Spades"

Note that Suit is an enumerated type. Your Card class should also implement the Comparable interface.Order cards with the different Suits ranked, from lowest to highest, as CLUBS, DIAMONDS, HEARTS, SPADES, and then in ascending order of their rank within the Suit

Deck.java

Implement a Deck class that keeps an ArrayList of cards. Provide the following API:

public Deck()

public String toString() // print all cards in deck

public boolean isDeckEmpty()

public Card deal() //deals the topmost card in deck

public void shuffle() //shuffles cards in deck

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!