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

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

Assignmentconsider the following declarationsclass

Assignment Consider the following declarations: class bagType { public: void set(string, double, double, double, double); void print() const; string getStyle() const; double getPrice() const; void get(double, double, dou ...

Intro to programming in c programming assignmentassignment

Intro to Programming in C Programming Assignment Assignment purpose: User defined functions, pointers, Menu driven program A Company needs to create software for their new line of phone applications. Customers will have ...

Discussionkeyboard versus file input please respond to the

Discussion "Keyboard versus File Input" Please respond to the following: • Suppose you are designing a C++ application that needs to capture user input specifically via a keyboard or from a file. Determine the method tha ...

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

Programming assignmentwrite a c program that allows the

PROGRAMMING ASSIGNMENT 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). The p ...

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

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 calculates and prints the average of

Write a C program that calculates and prints the average of two or more salaries entered by the user. The program should first prompt the user to enter the number of salaries to process (make sure: at least 2 salaries mu ...

1 create a c visual studio console application with the

1. Create a C++ visual studio console application with the name Project2. (As usual, to make the grader happy, it is critical that your project as well as your zip file contain your name and the exercise or project numbe ...

  • 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