This homework is aimed at getting you to use random numbers, vectors, and to read and write functions!
At the end of this homework, you should submit 3 files: Range.h that declares and documents functions you are to write, Range.cpp that defines those functions, and Game.cpp that has your main routine.
This is a one-player game that vaguely-ish resembles BlackJack. There are 3 identical rounds where a player attempts for the value of all cards in their hand to be within a fixed range. This range is randomly set each round.
Each card of a standard deck of 52 cards has a value associated with it.
In each round, a number from 17 to 22 inclusive is randomly chosen as a lower bound for the value of the user's hand. The player aims for the total value of all cards in their hand to reach or exceed the given target value, while at the same time ensuring the total value of their hand does not exceed 22!
At the start of every round, there is a full deck of 52 cards, represented by a std::vector< Card> (see the Card.h and Card.cpp files). Cards are dealt by a card being randomly selected from the deck and removed from it.
During a round, the target lower bound should be displayed and the user dealt a card if they have chosen so (except for the first card that will always be dealt). The total value of cards in the user's hand should be displayed along with the cards in their hand. Then,
If they choose to be dealt no more cards, they do not earn or lose any points, they are told they earned 0 points, and the next round, if there is one, commences.
A round should end if the user is within range, without them having to choose not to be dealt more cards!
When the game is over, the user's total score should be displayed.
Download the Card.h and Card.cpp files and include them in your workspace. Do not modify these files in any way. You must use the Card class in this assignent; some of the other functions included may also be of use to you. You will not submit either Card.h or Card.cpp in the end as they will be automatically included when the home- work is tested.
Write a Game.cpp that implements the game described above. The desired input and a sample outputs are provided.
You must define and use the following functions in nontrivial ways in your code (this is where Range.h and Range.cpp that you must write come into play):
The desired format is below:
Cards 2-10 are worth their numeric value.
J, Q, K have a value of 11.
An A has a value of 12 as a spade and 1 for other suits.
Over 3 rounds, you will try to reach or exceed a target value, without going over 22!
If you go over, you get -1 points; if you are within range, you get +1 points; otherwise
you get 0 points.
FOR EACH OF 3 ROUNDS [
UNTIL THE USER WINS OR LOSES OR CHOOSES TO ACCEPT NO MORE
CARDS [
Target lower bound:
[VALUE CHOSEN]
Hand value is:
[CORRECTLY COMPUTED HAND VALUE]
Hand is:
[LIST OF CARDS]
Deal more? y/n: [USER ENTERS āyā or ānā]
]
You got [SOME NUMBER] [POINT/POINTS]
]
Your total score is [CORRECT TOTAL] [POINT/POINTS].
The [] are not part of the display; they are just used to group the logic together. There might be nested loops, etc. Only one of "point" or points should display, depending on the number of points earned/displayed.