Purchase Solution

Develop a program that plays "Five Card Stud"

Not what you're looking for?

Ask Custom Question

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.

Attachments
Purchase this Solution

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Javscript Basics

Quiz on basics of javascript programming language.

C# variables and classes

This quiz contains questions about C# classes and variables.