Modified Version of Blackjack The Rules and Steps: One player plays against the Dealer (the computer). It is a win-or-lose game Blackjack – when the sum of points from all cards is 21. The dealer can...




Modified Version of Blackjack


The Rules and Steps:


One player plays against the Dealer (the computer). It is a win-or-lose game



  1. Blackjack – when the sum of points from all cards is 21.

  2. The dealer can not get a card when his points >= 17

  3. Whoever has reached the 21 first will win.






When the game starts, the dealer gets two cards, and the player also gets two cards,


Player Turn:


If the player's point is equal to 21 (Blackjack) the player wins


If the points > 21 (Over) the player lose.



  • Player decides if more card is needed if Yes, get the next card from the deck and stay in Player Turn

  • If not, go to Dealer Turn






Dealer Turn: The dealer must take another card if his points is less than 17 and stat in Dealer Turn


If the dealer’s point is equal to 21 (Blackjack) the dealer wins


If the points > 21 (Over) the dealer loses


Otherwise, dealer must have more than 17 and less than 21


Finally, compare points between player’s and dealer’s


If player’s >= dealer’s player wins


Else the dealer wins


Game ends






The Design:


You will have 4 classes: CardDeck, Player, Dealer, BlackJack (main game)


Player- this class stores the total points accumulated during the games, a list of the cards that stores the, points for each. The number of cards has been gotten.


Each player/Dealer will start with an cards[] array of up to 12 elements. Why (extra credit to be submitted via email with subject "Why 12 elements")?


It will have the following methods:



  • Player() – This is the CONSTRUCTOR, it will be called when a new player starts. It sets points = 0, card counts to and create an array of 11.

  • static void showPoints() - display the total points, note: Ace is 1 or 11, JQK are 10. If there is an Ace, you need to print two possible score/points.

  • static void showCards() - display the each card from the card array, print out the suit and the number of the cards. Spade is 0-12, Heart is 13-25; Diamond is 26-38 and Club is 39-51. J - 10, Q-11, K-12, Ace - 0. I expect to see output like: [Ace, Queen], or [1, 7, King]

  • static void isBlackjack() – return true if the total points is 21

  • static void isOver() - return true if the total points is larger than 21






Dealer – this class stores the total points accumulated during the games, a list of the cards that stores the points for each. The number of cards has been gotten.


Dealer will start with an cards[] array of up to 12 elements.


It will have the following methods:



  • Dealer()- will be called when a new game starts. It sets points = 0, card counts to

  • 0 and create an array of 12.

  • static void getCard()-get a randomly generated card points, then to be stored int the cards array

  • static void showPoints() - display the total points. Same as the player class.

  • static void showCards() - display the each card from the card array. Same as the player class.

  • static void isBlackjack() – return true if the total points is 21

  • static void isOver() - return true if the total points is larger than 21






CardDeck – one-dimensional array cardDeck[] has a size of 52 It will have the following methods:



  • static void shuffle (): rearranges the card[] in random order.

  • static int nextCard(): return the next card from the card[] , note that you will need a variable to keep track of the index of the cardDeck[] by increasing the index count every time when this method is called.






BlackJack (the Game) - start with new CardDeck, Player and Dealer. Implements the logic described above using class methods and primitive operations.

Feb 23, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here