Implement the hand as an array of five cards


Assignment:

Develop a program that plays "Five Card Stud". The user plays agains the computer. The program will "deal" five cards to the user and itself. Whoever has the highest hand wins. Inform the user who has won that hand, and ask if the user wants to play again. Interaction is as follows:

Your hand is:
2 of hearts
3 of diamonds
4 of clubs
2 of clubs
3 of hearts

My hand is:
Ace of clubs
Ace of hearts
Ace of diamonds
King of clubs
King of hearts

I win, sorry...

Play again (y,n)? n

Thanks for playing.

You need to develop 4 classes for this program. They are the Card, Deck, and Hand classes and the class containing your main method.

The Card class must contain (at least) the following methods:

Card() - constructor that initialized the value and suit of the Card
getValue() - returns the current value of the Card
getSuit() - returns the current suit of the Card

equals() - returns true when the passed Card is equal to the current Card
compareTo() - compares two Cards (passed and current) returning -1, 0 or 1
toString() - returns the string representation of the current Card, i.e. "King of hearts"

The Deck class must contain (at least) the following methods:

Deck() - constructor that initializes the Deck of Cards
shuffle() - shuffles the Deck
deal() - returns the Card on the top of the Deck

Implement the Deck as an array of Cards.

The Hand class must contain (at least) the following methods:

equals() - returns true when the passed Hand is equal to the current Hand
compareTo() - compares two Hands (passed and current) returning -1, 0 or 1
toString() - returns the string representation of the current Hand, i.e. "King of hearts\n2 of clubs\n etc..."

Implement the Hand as an array of five Cards.

The fourth class is your main method class. It is implemented procedurally.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Implement the hand as an array of five cards
Reference No:- TGS01935260

Now Priced at $25 (50% Discount)

Recommended (98%)

Rated (4.3/5)