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++

Programming assignment 5write a c program that allows the

PROGRAMMING ASSIGNMENT #5 Write a C program that allows the user to make some banking transactions. The program should first prompt the user to enter the current balance of his/her bank account (in dollars and cents, not ...

Write a c program that requests the name of any cartoon

Write a C program that requests the name of any cartoon character from the user, then does the following with that name (use printf for each): a. Displays it enclosed in double quotes. b. Displays it in a field 24 charac ...

Write a program that reads numbers from cin and then sums

Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Construct three versions of this program, using the while, do - while , and for loops. Add the following to your program: ...

Projectdecision statementsdirections read carefully and

Project: Decision Statements Directions (Read CAREFULLY and follow COMPLETELY): - Create the following programs in C++ that perform the purpose described and show the sample output (with user input where applicable). - I ...

Assignmentgoals developing problem-solving skills declaring

Assignment Goals: Developing problem-solving skills, declaring variables, multi-way branches, data validation. Problem: Complete Programming Challenge 4.19 in your text book. Do not accept values larger than 10 meters or ...

Write a c program that prompts the user to enter a line of

Write a C program that prompts the user to enter a line of text (up to 50 characters). It should then convert the text entered to uppercase letters and then to lowercase letters, and then to Sentence case. Your program s ...

C projectphase 11- you need to take input from user study

C project Phase 1 1- You need to take input from user study year (proper value check from 1 to 4) 2- Take input semester (proper value check 1 to 8) 3- Calculate GPA (use Loop, calculate GPA for semester 1,2,3...) Exampl ...

Assignmentpart acomplete the following questionswrite c

Assignment Part A Complete the following questions: Write C++ code to open a document with the name Hello.txt, place the message "Hello, World!" in the document, and exit the document. Re open the file you closed, and re ...

Writing a c code its a beginner level code design a class

Writing a C++ code, its a beginner level code. Design a class house that defines a house on a street. A house has a house number and an (x,y) location, where x and y are numbers between -10 and 10. the key member is plot ...

Programming assignment image processing - pointers class

Programming Assignment: Image Processing - Pointers, Class & Dynamic Data This project is called "Image Processing" which will shrink an input image, convert a color image to gray image , add random noise to an image, ad ...

  • 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

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen