Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part A-1: Setup 1. C# Console Application 2. C# .Net Class Library Part A-2: enums Create 2 enums to represent the data for a Suit

Part A-1: Setup

1. C# Console Application

2. C# .Net Class Library

Part A-2: enums

Create 2 enums to represent the data for a Suit and Face.

CardSuit: Spades, Hearts, Clubs, Diamonds

CardFace A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K

Part A-3: ICard

Create an interface to represent the public interface for a Card.

Add the following properties to the interface: Face, Suit. ONLY have a get do not put a set on the properties. Use the enums for the Face and Suit.

Add a Draw method. It should not return anything but take 2 int parameters: x and y. NOTE: interfaces cannot have any code so just put the method signature.

image text in transcribed

Part A-5: The Card Factory class:

Create a static factory class that will have a static method for creating cards.

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Part A-4: The Card Class Create a Card class. Implement the ICard interface. The properties should have private setters. Add a constructor to the Card class that takes 2 parameters for face and suit. Also add a Draw method that will draw the card starting at the specified x,y position in the console window. PROPERTIES NAME TYPE COMMENTS Suit Face CardSuit CardFace Make the setter private Make the setter private METHODS RETURNS NAME Card PARAMETERS face, suit COMMENTS A parameterized constructor for the Card class. Set the properties of the class to the values passed in the parameters. Draws the card starting at the x,y position in the console. Draw void RETURNS NAME CreateCard PARAMETERS face, suit iCard COMMENTS A static method that creates a Card instance using the parameters and returns it. Part A-6: The Deck Class You can't play a card game without a deck of cards, so you'll want to add a Deck class. The Deck class has data (list of cards) and behavior (Shuffle, Draw). The constructor for the Deck class should generate all 52 cards (4 suits * 13 cards per suit). You can do it in the constructor or call a method that creates the cards. Call the Card Factory to create the card instances. Shuffle should reorder the cards in the list to mimic real-life shuffling. Deal should return 1 card from the top of the deck. You'll need to consider what to do when the deck is empty. The dealer will use the Deal method to get a card from the deck and add it to the player's / dealer's hand. FIELDS NAME _cards TYPE List COMMENTS Initialize in the constructor or in the declaration METHODS NAME RETURNS PARAMETERS Deck Deal (none) (none) ICard COMMENTS A constructor that initializes the list of cards. Returns a card from the list of cards. Recreate the deck if the list of cards is empty. Reorders the cards in the list to mimic real-life shuffling Shuffle void (none) Part A-7: The Hand Class You'll want a Hand class to hold the cards for a player or dealer. Each player is dealt cards. Those cards that the player has is consider the player's Hand. A Hand class can have data (list of cards) and behavior (AddCard). AddCard should take a card as a parameter and add it to the list of cards for the Hand. A444 Al Draw should take x,y parameters. They will serve as the starting top-left coordinates for where to start drawing the cards. The Draw method should draw the cards horizontally meaning that the starting y position for each card would be the same but the starting x position of each card will be different. FIELDS NAME _cards TYPE List COMMENTS Initialize in the constructor or in the declaration. Make this field protected. RETURNS PARAMETERS METHODS NAME AddCard Draw ICard void void COMMENTS Adds the card to the list of cards Calls the Draw method of each card in _cards. Draw the cards horizontally, the y would be the same for each card but the x would change. X,Y Part A-8: The Menu Add a menu loop to the Main method in Program.cs of your Console application. Your game's main menu should give them 3 options: Play Blackjack, Shuffle & Show Deck, Exit. 1. Play Blackjack. a. This is the menu entry to start playing blackjack. (Complete this part for the final Blackjack project) 2. Shuffle & Show Deck. a. This option first shuffles the deck and then displays all the cards of the deck. 3. Exit a. exits the app 1. Play Blackjack 2. Shuffle and Show Deck 3. Exit Choice: Part A-9: Card appearance Using the functions of the Console class, come up with a way of representing the cards as more than just a number and a single character for the suit. What about writing a white box to the screen, with red or black letters depending on the suit? The minimum should be a different background color for the card (white?), a symbol for the suit and the card face. Or you could go bigger! 10 10 Part B-2: BlackjackHand class Create a BlackjackHand class that derives from the Hand class from Part A. A Blackjack Hand has a score property as it pertains to the Blackjack game. You will need to override the AddCard method to update the score of the hand after calling the base AddCard method. You will need to override the Draw method: draw the score and if it's a dealer hand, hide the first card. The Score is the sum of the values of all the cards in the Hand. The Score should be the best score possible that is closest to 21. Aces make scoring tricky because the Aces value could change based on the other cards in the Hand. For instance, if the player has these cards in the Hand (Ace, 8), the score should be 19 (11 + 8). If a 6 card is added to the Hand, the Score would then become 15 (1 +8+6), not 25 (11 +8+ 6). NAME Score IsDealer TYPE Int COMMENTS The Blackjack score of the hand. Make the setter private. True if the hand is the dealer's hand. Default the value to false. Bool METHODS NAME RETURNS PARAMETERS COMMENTS BlackjackHand (none) isDealer Make the isDealer parameter an optional parameter with the default value being false. Use isDealer to set the IsDealer property. AddCard void Override the AddCard method to update the score of the hand after calling the base AddCard method Draw void X,Y Override the Draw method of the Hand class. In addition to drawing the cards, draw the score and if it's a dealer hand, hide the first card. NOTE: to update the score, you'll have to cast the ICard card to a BlackjackCard that has a Value property. Card Part B-3: Update the Factory Add a new method to the Card Factory that will create an instance of the BlackjackCard. Update the Deck class to call CreateBlackjackCard when creating cards. METHODS NAME RETURNS PARAMETERS CreateBlackjackCard Card face, suit COMMENTS A static method that creates a BlackjackCard instance using the parameters and returns it. Part B-4: Unit Test The scoring of your Blackjack hand is critical to your game working correctly. To add a Unit Test project easily, right-click the BlackjackHand class and select "Create Unit Test..." Write a unit test for a BlackjackHand AddCard method. o Create an instance of the BlackjackHand o Call AddCard twice and add 2 cards: an Ace and an 8. o Test that the score should be 19. Add a Ten to the hand using the AddCard method. o Test that the score should still be 19. Part A-4: The Card Class Create a Card class. Implement the ICard interface. The properties should have private setters. Add a constructor to the Card class that takes 2 parameters for face and suit. Also add a Draw method that will draw the card starting at the specified x,y position in the console window. PROPERTIES NAME TYPE COMMENTS Suit Face CardSuit CardFace Make the setter private Make the setter private METHODS RETURNS NAME Card PARAMETERS face, suit COMMENTS A parameterized constructor for the Card class. Set the properties of the class to the values passed in the parameters. Draws the card starting at the x,y position in the console. Draw void RETURNS NAME CreateCard PARAMETERS face, suit iCard COMMENTS A static method that creates a Card instance using the parameters and returns it. Part A-6: The Deck Class You can't play a card game without a deck of cards, so you'll want to add a Deck class. The Deck class has data (list of cards) and behavior (Shuffle, Draw). The constructor for the Deck class should generate all 52 cards (4 suits * 13 cards per suit). You can do it in the constructor or call a method that creates the cards. Call the Card Factory to create the card instances. Shuffle should reorder the cards in the list to mimic real-life shuffling. Deal should return 1 card from the top of the deck. You'll need to consider what to do when the deck is empty. The dealer will use the Deal method to get a card from the deck and add it to the player's / dealer's hand. FIELDS NAME _cards TYPE List COMMENTS Initialize in the constructor or in the declaration METHODS NAME RETURNS PARAMETERS Deck Deal (none) (none) ICard COMMENTS A constructor that initializes the list of cards. Returns a card from the list of cards. Recreate the deck if the list of cards is empty. Reorders the cards in the list to mimic real-life shuffling Shuffle void (none) Part A-7: The Hand Class You'll want a Hand class to hold the cards for a player or dealer. Each player is dealt cards. Those cards that the player has is consider the player's Hand. A Hand class can have data (list of cards) and behavior (AddCard). AddCard should take a card as a parameter and add it to the list of cards for the Hand. A444 Al Draw should take x,y parameters. They will serve as the starting top-left coordinates for where to start drawing the cards. The Draw method should draw the cards horizontally meaning that the starting y position for each card would be the same but the starting x position of each card will be different. FIELDS NAME _cards TYPE List COMMENTS Initialize in the constructor or in the declaration. Make this field protected. RETURNS PARAMETERS METHODS NAME AddCard Draw ICard void void COMMENTS Adds the card to the list of cards Calls the Draw method of each card in _cards. Draw the cards horizontally, the y would be the same for each card but the x would change. X,Y Part A-8: The Menu Add a menu loop to the Main method in Program.cs of your Console application. Your game's main menu should give them 3 options: Play Blackjack, Shuffle & Show Deck, Exit. 1. Play Blackjack. a. This is the menu entry to start playing blackjack. (Complete this part for the final Blackjack project) 2. Shuffle & Show Deck. a. This option first shuffles the deck and then displays all the cards of the deck. 3. Exit a. exits the app 1. Play Blackjack 2. Shuffle and Show Deck 3. Exit Choice: Part A-9: Card appearance Using the functions of the Console class, come up with a way of representing the cards as more than just a number and a single character for the suit. What about writing a white box to the screen, with red or black letters depending on the suit? The minimum should be a different background color for the card (white?), a symbol for the suit and the card face. Or you could go bigger! 10 10 Part B-2: BlackjackHand class Create a BlackjackHand class that derives from the Hand class from Part A. A Blackjack Hand has a score property as it pertains to the Blackjack game. You will need to override the AddCard method to update the score of the hand after calling the base AddCard method. You will need to override the Draw method: draw the score and if it's a dealer hand, hide the first card. The Score is the sum of the values of all the cards in the Hand. The Score should be the best score possible that is closest to 21. Aces make scoring tricky because the Aces value could change based on the other cards in the Hand. For instance, if the player has these cards in the Hand (Ace, 8), the score should be 19 (11 + 8). If a 6 card is added to the Hand, the Score would then become 15 (1 +8+6), not 25 (11 +8+ 6). NAME Score IsDealer TYPE Int COMMENTS The Blackjack score of the hand. Make the setter private. True if the hand is the dealer's hand. Default the value to false. Bool METHODS NAME RETURNS PARAMETERS COMMENTS BlackjackHand (none) isDealer Make the isDealer parameter an optional parameter with the default value being false. Use isDealer to set the IsDealer property. AddCard void Override the AddCard method to update the score of the hand after calling the base AddCard method Draw void X,Y Override the Draw method of the Hand class. In addition to drawing the cards, draw the score and if it's a dealer hand, hide the first card. NOTE: to update the score, you'll have to cast the ICard card to a BlackjackCard that has a Value property. Card Part B-3: Update the Factory Add a new method to the Card Factory that will create an instance of the BlackjackCard. Update the Deck class to call CreateBlackjackCard when creating cards. METHODS NAME RETURNS PARAMETERS CreateBlackjackCard Card face, suit COMMENTS A static method that creates a BlackjackCard instance using the parameters and returns it. Part B-4: Unit Test The scoring of your Blackjack hand is critical to your game working correctly. To add a Unit Test project easily, right-click the BlackjackHand class and select "Create Unit Test..." Write a unit test for a BlackjackHand AddCard method. o Create an instance of the BlackjackHand o Call AddCard twice and add 2 cards: an Ace and an 8. o Test that the score should be 19. Add a Ten to the hand using the AddCard method. o Test that the score should still be 19

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

From Zero To Data Hero With Chatgpt

Authors: Andrew Wu

1st Edition

B0CQRJPXD9, 979-8989523009

More Books

Students also viewed these Databases questions

Question

How has your firm responded to these trends?

Answered: 1 week ago

Question

3. Evaluate your listeners and tailor your speech to them

Answered: 1 week ago