Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

Lab: OOP Blackjack

In this lab, you will develop a simple game of blackjack using object oriented programming.

UML Class Diagrams:

Your project must implement the following classes:

186_blackjack.jpg

class BlackJack:

The role of the Blackjack class is to encapsulate all of logic associated with playing the game of blackjack.

Note that all output visible in the Sample Output section is generated by BlackJack's play() method.  The play() method should operate as follows:

Program Start:

1.  Output an introduction

Starting with the player, do the following:

1.  Deal the player a card.

2.  Add the card's value to the player's total hand. 3.  Output the value of the card just dealt and the player's current hand total (score)

3.  Ask the player if he would like to hit or stand

4.  If the player hits, go back to #1

After the player busts (goes over 21) or stands

1.  If the player has not busted, begin computer's play
2.  Deal the computer a card
3.  Add the value of the card to the computer's hand total (score)
4.  If a card causes the computer to bust (go over 21), output a message.  Go to step #7.
5.  If the computer's hand total is less than 17, it must take another card (hit).  Go to step #2. 
6.  If the computer's hand is 17 or more, the computer stands.
7.  Stop computer play

When both player and computer are done:

1.  If the player has not busted (gone over 21) and the computer busted, the player wins.

2.  If the player has not busted, the computer has not busted, and the player's hand total is greater than the computer, then the player wins.

3.  If the player has not busted, the computer has not busted, and the player's hand total is less than the computer's then the computer wins.

4.  If the player has busted, then the computer wins.

class Card:

We use the card class to represent an individual card in a deck.  Cards have a suit (Club, Diamond, Heart, Spade) and a rank (e.g. Two, Ten, Jack, Ace).  Suit_t and Rank_t are enumerations that list the possible values.  To simplify, we will assume that aces only play one role in blackjack and have a value of 11.

Note that the Card class has a getRankValue() method that will return the integer value of the card (i.e. 2-11 depending on the card's base value).

class Deck:

The Deck class is merely a collection of 52 cards. The private member variable "_used_indices" is used to track the cards previously dealt.  Calling the resetDeck() method should re-initialize the deck of cards and clear out the list of previously dealt cards. For convenience, the Deck's constructor should automatically call resetDeck() to initialize the deck.

C/C++, Programming

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

Have any Question? 


Related Questions in C/C++

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

C program codeoverviewfor this assignment write a program

C++ program code Overview For this assignment, write a program that will simulate a single game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the die will determi ...

Text exercise 413 gas mileagebulldrivers are concerned with

Text Exercise 4.13 (Gas Mileage) • Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several trips by recording miles driven and gallons used for each trip. Develop a C++ ...

Write an application that allows the user to enter two

Write an application that allows the user to enter two variables: number (real) and code (character). Calculate the value indicated by the table below: If code is Result A symbol the whole part of the number everything e ...

Assignment simple 5-card poker gamein this assignment you

Assignment: 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 discussed in class. Flow of Play Your poker game's p ...

Programwriteacprogramthatwillasktheuserforthenameofaninputfi

Program Write a C++ program that will: Ask the user for the name of an input file. Read in this name and open that text file for input. Ask the user which of two options they want to do: Read in student data Count lines ...

Problem 1overview for problem 1a of this assignment you

Problem #1 Overview: For problem 1(a) of this assignment, you will need a C++ compiler. In order to receive credit, your program must compile and run; and you must provide the actual source code file so that I can compil ...

Write code to create the generator submit your source code

Write code to create the generator. Submit your source code as well as a description of how I could run the program, sample screenshots of the program in action, and the various changes that could be produced through you ...

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

C program assignmentaccording to C Program Assignment According to

C Program Assignment According to http://en.wikipedia.org/wiki/Great-circle_distance, the great circle distance based on two coordinates in nautical miles is given by: d = r * Δσ where r is the radius of the earth and Δσ ...

  • 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