CSC 212 - Homework #6
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 heartsn2 of clubsn etc..."
Implement the Hand as an array of five Cards.
The fourth class is your main method class. It is implemented procedurally.© BrainMass Inc. brainmass.com October 16, 2018, 2:49 pm ad1c9bdddf - https://brainmass.com/computer-science/java/develop-program-plays-five-card-stud-148585