Ask Question, Ask an Expert

+61-413 786 465

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

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

  • 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

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As