You will implement a C# console application that lets a human "guest" play multiple rounds of casino-style Blackjack against a computerized "house" player. (In the usual game, there are multiple "guest" players who all play against the "house" player at the same time. In this assignment, there is only one "guest" --- the human. The rules below are for the game when one or more guest players compete against the one house player.)
Important: for all players, guest and house players, the value of the first of the two cards from each player's hand is revealed to all. Of course, the human sees the values of both cards in her own hand.
If the house player does not have Blackjack, then the dealer looks at the scores of each of the guest players. Every guest player who has Blackjack wins the round. (When there are multiple guest players, there can be multiple winners of a round.) Important: Every guest player who has won the round does not participate in Steps 3 and 4 that follow.
Important: the human guest player decides whether to accept more cards. The house player in your implementation is computerized and will accept another card as long as the house player's hand has a score that is less than 17.
The game keeps going for multiple rounds --- indeed, forever --- and it displays at the end of each round (i) the number of rounds played so far, and (ii) for each guest player (in this assignment, the human) the number of the player's wins. (We won't keep track of "losses" or "ties".)
Recall that a face card has value 10, a numbered card has its number as its value, and an Ace can have value either 1 or 11. This means a hand of cards can have multiple possible scores. The score of a hand of cards is the largest int that is <= 21 if possible, else the smallest int that is > 21. (Example: if the hand is "Ace of Hearts", "Ace of Clubs", and "8 of Diamonds", the score of the hand is 20. Another example: if the hand is "Ace of Hearts", "6 of Spades", "Jack of Diamonds", and "5 of Clubs", the score is 22, because a score <= 21 is impossible.)
=================================================== Welcome to Blackjack! New round: Your top card is: 3 of Clubs The house player's top card is: 8 of Hearts The house player does NOT hold a blackjack, so play continues: Your hand is: 3 of Clubs Ace of Diamonds The score is: 14 Do you want another card (y or n)? y Your hand is: 3 of Clubs Ace of Diamonds Ace of Spades The score is: 15 Do you want another card (y or n)? y Your hand is: 3 of Clubs Ace of Diamonds Ace of Spades 4 of Clubs The score is: 19 Do you want another card (y or n)? n The house player's hand is: 8 of Hearts 7 of Spades The score is 15 The house player's hand is: 8 of Hearts 7 of Spades Queen of Hearts The score is 25. A bust! You win! After 1 rounds, you have 1 wins. Do you want to play another round (y or n)? (AND SO ON...) ===================================================Perhaps the console input/output is not so attractive, but it lets us concentrate on the operation of the game. (Large systems are often prototyped in this way --- with a simplistic user interface that is later replaced by a better-looking one.) In a subsequent assignment, we will add graphics to the user interface.
Do this part once you have your game operating properly: When subsequent rounds are played, the dealer continues to deal from the same deck. When the deck runs empty (and this will usually happen in the middle of a round of play), then the dealer must continue by dealing from all the previously used cards (the "discards") as the new deck. (Do not construct a new Deck object! Use the cards/deck that you started with.)
The cards that are already in the hands of the players stay where they are. This means you must improve the coding of the deal method in class Deck and you will need to code a new method in class Deck that reclaims previously used cards. class Hand will likely need a new method to surrender its cards and reset to an empty hand.
You must write and include unit tests for all classes in CardConcepts and the new classes you write. (You've done much of the work already in lab.) Include the unit tests in the UnitTests project.
Use Visual Studio's debugger with breakpoints if you need to see the values saved in storage during the tests.
CardConcepts is a Class Library and its executable code is saved as a dll file. This VS Solution must be kept separate and will be used in a later assignment. So, you must construct a second Visual Studio Solution --- a Console Application named Blackjack --- that holds the code you write for playing the Blackjack game.
Here is a package diagram that shows the structure of your work:
MyLastName.MyFirstName.Assn1 (Folder)
+---------------------------------------------------------
|
| CardConcepts (VS Solution)
| +-------------------------------------------------------
| | CardConcepts (VS Project) UnitTests (VS Project)
| | +------------------- +------------------
| | | class Card, class Hand, | unit tests go here
| | | class Deck |
| +--------------------------------------------------------
|
|
| Blackjack (VS Solution) (the card game you write)
| +-----------------------------------------------------
| | Blackjack (VS Project) UnitTests (VS Project)
| | +---------------------- +----------------------
| | | your work goes here | if there are classes in
| | | | Project Blackjack to unit-test
|
+--------------------------------------------------------------
Once you complete your work, run a sample session where you play the game for at least 3 rounds. Copy the output from your play into a text file, test.txt. (If you don't know how to Mark-Copy-Paste from an MS command window into a text file, ask me!)
The teaching assistant will study your work and apply some additional tests. I will also study your work. Later we will meet one-on-one to discuss the work.