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

Computer sciencewhere do you think c and coding games in c

Computer Science Where do you think C++ and coding games in C++ is headed in the next five years? How about in the next 10 years? Do you think there are any significant improvements that need to be made to the code to en ...

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 part acreate a checkbook program using c

Assignment (part a) Create a Checkbook program using C : • Create a Check structure. Include:   o Check number (should be an integer).   o Date (use type char[ ]).   o To   o Amount   o Description • Add functions to:   ...

Assignmentthis is the programthis program will use 2

Assignment This is the program: This program will use 2 different data structures to perform the same tasks; a vector and a dynamically sized array Write a complete C++ program that will: Declare a vector of integers wit ...

Discussionwhile loops versus for loops please respond to

Discussion "While Loops versus For Loops" Please respond to the following: • Suppose you are writing a C++ program that plays a commercial video continuously within a kiosk at your favorite shopping mall within your home ...

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

Assignmentthis assignment gives you the opportunity to

Assignment This assignment gives you the opportunity to practice array of pointers, linked lists and self referential structures. Write a program that initializes two parallel arrays as follows: char * String[] = { "Abbi ...

Assignmentbullwrite the code for each lab

Assignment • Write the code for each lab assignment. • Submit the lab in a single zip file in the online course shell. The lab must contain all .cpp files, along with any additional files that may be necessary for your p ...

Assignmentwhen writing c programs include comments in your

Assignment When writing C++ programs include comments in your code, make the program readable by indenting, use meaningful variable and function names, and produce meaningful output. This assignment will be to write a te ...

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

  • 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