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 compiler that translates a high-level language into

A compiler that translates a high-level language into another high-level language is called a source-to-source translator. What advantages are there to using C as a target language for a compiler?

Transaction processing system tpsxyz electronics is one of

Transaction Processing System (TPS) XYZ Electronics is one of the most popular electronics companies In Sultanate of Oman the company offers affordable electronic gadgets such as mp3 players, portable movie players, mobi ...

Modules in c are called functions c programs are typically

Modules in C are called functions. C programs are typically written by combining user created functions as well as "pre-packaged" functions found in the C Standard Library. For instance, printf() is a function that is fo ...

Assignment a random mazewrite a new c program with the

Assignment (a) Random Maze Write a new C++ program with the following functionality: The program writes a greeting on the screen. Then the program displays a maze of ASCII symbols on the screen. The maze consists of 8 ro ...

Write a c application that does the followingitem 1 prompts

Write a C++ application that does the following: ITEM 1: Prompts the user to choose one of the following series: 1 + 1/2 + 1/3 + ... + 1/n ((((x * 2) * 2) * ...) * 2) series of n multiplications x + (x * 1) + (x * 2) + ( ...

C-programmingcreate a c program that sorts a sequence of

C-Programming Create a C program that sorts a sequence of positive numbers using the bubble sort algorithm in an increasing or decreasing order based on the user's choice. The pseudo code for the bubble sort algorithm is ...

Cosci 21a programming assignmentpurpose experience with

COSCI 21a, Programming Assignment Purpose: Experience with some basic data structures, including circular queues, linked lists, hash tables, and specifically with pointers and the associated dynamic memory allocation. Pr ...

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: ...

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

Create your own unique while-end repetition structure you

Create your own unique While-End repetition structure. You decide the theme. You should provide both the pseudocode and the flowchart of your example. Be sure to provide an overview of what your repetition structure is d ...

  • 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

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

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