Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The objective of this assignment is to implement a basic API for Card games, and then code a simple Card game Card.iava Define a Card

image text in transcribedimage text in transcribedimage text in transcribed

The objective of this assignment is to implement a basic API for Card games, and then code a simple Card game Card.iava 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.iava 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 Hand. java Then define a Hand class, that is a set of cards held by a player. This class also keeps an ArrayList of cards and should support the following API: public Hand (int m) //specifies initial size of hand public Card drawNext) //draws "next" card from hand public Card draw(String s) //draws specific card from hand, in format "8s", "1c", "11h", "13d" public void addCard (Card c) //adds card to hand public ArrayList getCards) // gets the list of Cards in hand Define the following custom exception classes, and throw them at appropriate places in the preceding classes CardException extends RuntimeException DeckOrHandEmptyException extends CardException InvalidCardException extends CardException The objective of this assignment is to implement a basic API for Card games, and then code a simple Card game Card.iava 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.iava 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 Hand. java Then define a Hand class, that is a set of cards held by a player. This class also keeps an ArrayList of cards and should support the following API: public Hand (int m) //specifies initial size of hand public Card drawNext) //draws "next" card from hand public Card draw(String s) //draws specific card from hand, in format "8s", "1c", "11h", "13d" public void addCard (Card c) //adds card to hand public ArrayList getCards) // gets the list of Cards in hand Define the following custom exception classes, and throw them at appropriate places in the preceding classes CardException extends RuntimeException DeckOrHandEmptyException extends CardException InvalidCardException extends CardException

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago