Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

Homework: Simple 5-Card Poker Game

In this assignment, you will develop a simple poker game, complete with basic AI, using the object oriented programming principles.

UML Class Diagram:

Your assignment must contain and use the following classes:

530_poker gane.jpg

Card and Deck Classes:

The Card and Deck classes are direct carryovers from Lab #2.  For more information about these classes, see the Lab #2 document on the course website.

Hand Class:

You will need two instances of the Hand Class in your game: one for the player and one for the computer.  Each Hand will contain the respective player's current hand of cards.  The hand class must have several helper methods that can be used to determine the strength of the hand.  If you are unfamiliar with poker hands, Wikipedia has a related article that may be of interest.

PokerGame:

Like the BlackJack class in Lab #2, the PokerGame class will be used to encapsulate all of the logic associated with playing the game of poker.  The play method's operation will be discussed in the next section.

Flow of Play:

Your poker game's play() method should operate as follows:

A) Deal the player five cards and display the results on the screen

B) Ask the player which cards he or she would like to exchange

C) Remove the desired cards from the player's hand

D) Deal the player N new cards (N = exchange amount)

E) Display the new hand on the screen

F) Deal the computer five cards and display the results on the screen

G) The computer determines how many cards to exchange based on the following logic:

•    Zero cards if the computer has a four of a kind, full house, straight, or flush
•    One card if the computer has two pair
•    Two cards if the computer has three of a kind
•    Three cards if the computer has a pair
•    Five cards if the computer has none of the above

H) Remove the appropriate number of cards in the computer's hand

I) Deal the computer the appropriate number of replacement cards

J) Display the new hand on the screen

K) Determine the winner of the game based on the following rankings:

•    Four of a kind
•    Full house
•    Flush
•    Straight
•    Three of a kind
•    Two Pair
•    Pair
•    High Card (ordered by Spade, Heart, Diamond, with Club being the lowest)

L) Indicate the winner on the screen

Sample Output:

*** Simple 5-Card Poker ***

The cards have been shuffled and you are dealt:

1. Five of Hearts
2. Five of Spades
3. Jack of Hearts
4. Two of Clubs
5. Ace of Diamonds
Indicate the cards that you would like to exchange (-1 to end):
4
3
6
Invalid selection.  

Indicate the cards that you would like to exchange (-1 to end):
-1
 Your new hand is:
1. Five of Hearts
2. Five of Spades
3. Two of Clubs
4. King of Hearts
5. Ace of Diamonds
The computer is dealt the following cards:
1. Ace of Spades
2. Three of Spades
3. Five of Diamonds
4. Ace of Hearts
5. Six of Clubs

The computer exchanges cards 2, 3 and 5.  The new hand is:

1. Ace of Spades
2. Seven of Clubs
3. Seven of Diamonds
4. Ace of Hearts
5. Queen of Diamonds
You have one pair.
The computer has two pair.
The computer wins.


Header Comment and Formatting:

1. Be sure to modify the file header comment at the top of your script to indicate your name,  student ID, completion time, and the names of any individuals that you collaborated with on the assignment.

2.  Remember to follow the basic coding style guide.

Required Game Play Components:

a) The program randomly deals cards to both the player and the computer.
b) The program prompts the user for cards to exchange.
c) The program correctly identifies and handles invalid input during the card exchange phase.
d) The program deals the requested number of cards to the player after the exchange phase.
e) The computer selects the number of cards to redraw based on the algorithm outlined in the "flow of play" section.
f) The program correctly determines the winner of a given game.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M954

Have any Question? 


Related Questions in C/C++

A write an array implementation of self-adjusting lists in

a. Write an array implementation of self-adjusting lists. In a self-adjusting list, all insertions are performed at the front. A self-adjusting list adds a find operation, and when an element is accessed by a find, it is ...

This program involves using stl listsfor this program you

This program involves using STL lists. For this program you will implement three functions whose prototypes are given below: list ::iterator mxIter(list ::iterator first, list ::iterator last); void selectSort(list & aLi ...

More often than not entrepreneurs will fail several times

"More often than not, entrepreneurs will fail several times before they make it and will usually learn a lot in the process. To help these entrepreneurs to succeed will require a cultural shift. We need to encourage Aust ...

Question 1you are facing the following problem you are

Question 1 You are facing the following problem: You are given a robot and your task is to "guide" the robot through a 2-dimensional maze such that the robot can reach a desired goal state. Assume that the maze is define ...

Programming assignment-1 program specification1 your

Programming Assignment- 1. Program Specification 1. Your program must read 8-bit ASCII strings from standard input -- for instance, using the cin object in C++, or stdin in C. You must consume all input from standard inp ...

1 learner objectivesat the conclusion of this programming

1. Learner Objectives: At the conclusion of this programming assignment, participants should be able to: * Apply repetition structures within an algorithm * Construct while (), for (), or do-while () loops in C * Compose ...

1 requirementsin this assignment you can unleash your

1. REQUIREMENTS In this assignment, you can unleash your imaginations and use OpenGL with C/C++ programming to produce a scene(s) that represents what you envision could possibly be seen under the sea. Please note that a ...

Descriptionnbspin this assignment you will write a c

Description:  In this assignment you will write a C++ program that finds the kth largest number among a set of N numbers. It will implement the solution using two different algorithms and measure the time elapsed during ...

For this program you will add and test 2 new member

For this program you will add and test 2 new member functions to the IntSLList class posted on the website. The two member functions are: insertByPosn(int el, intpos) Assuming that the positions of elements of a list beg ...

Pa 1 word countertabulating basic document statistics is an

PA #1: Word Counter Tabulating basic document statistics is an interesting exercise that leverages your knowledge of strings, files, loops, and arrays. In this homework, you must write a C++ program that asks the user fo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate