Question
JAVA Blackjack Solitaire Problem: The design of the code will follow the functionality of Blackjack Solitaire (https://www.solitairenetwork.com/solitaire/blackjack-square-solitaire-game.html). The concept of Blackjack is to stay at
JAVA Blackjack Solitaire Problem:
The design of the code will follow the functionality of Blackjack Solitaire (https://www.solitairenetwork.com/solitaire/blackjack-square-solitaire-game.html).
The concept of Blackjack is to stay at or below a value of 21 with the card(s) that you are dealt. With nine hands formed by four rows and five columns of a grid with the cards laid out, you draw cards one at a time from the deck and place them on the grid. Once placed, they cannot be moved, and there are four discard spots to remove them without placing them in the main grid.
Every card has a value - cards from 2 to 10 have the value of the number associated with the card. Face cards (King, Queen, Jack) are worth 10 points. Ace cards either count for 11 or 1 depending on which would give you a higher score. The scoring system is as follows:
Hand | Points | Details |
Blackjack | 10 | Blackjack is two cards that total 21 |
21 | 7 | 3, 4 or 5 cards totaling 21 |
20 | 5 | Hand totals 20 |
19 | 4 | Hand totals 19 |
18 | 3 | Hand totals 18 |
17 | 2 | Hand totals 17 |
Bust | 0 | Hand totals 22 or more |
16 and others | 1 | Hand totals 16 or less |
Instructions - write a series of code to do the following:
1. The game will play one hand and exit, meaning there will be 16 spots on the grid that should be filled (with 4 spots on the discard pile). A score is then calculated, the the game ends.
2. The 16 grid spots and 4 discard spots are numbers 1 - 20 as showing here:
1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 |
N/A | 11 | 12 | 13 | N/A |
N/A | 14 | 15 | 16 | N/A |
The discard spots are 17, 18, 19, and 20. The spots with N/A should not be used.
3. To display the progress of the game, the grid above should be used. The card should be displayed as the rank and suit. For example, the Ace of Spades would be AS, 8 of Clubs 8C, 5 of hearts 5H, Queen of diamonds QD, etc. Each spot on the grid will either have the number (meaning no card has been placed there yet) or will have the representation of the card. Example shown below:
1 | 2 | 7H | 3C | 5 |
6 | 5D | 8 | 9 | 10 |
N/A | 11 | KD | QH | N/A |
N/A | 14 | AS | 16 | N/A |
4. After a card is placed anywhere on the grid or the discard pile, a new card is dealt.
5. When all slots of the grid are filled (16 cards have been placed in the grid) the game comes to an end and the score is calculated.
6. If the user tries to place a card onto a slot on the grid that is already taken, the code should print an error message and repeat the prompt.
7. 4 classes should be created: 1) BlackjackSolitaire class that represents the whole game. 2) BlackjackSolitaireStart that runs the game. 3) Deck class that is the deck of cards. 4) Card class that is a single card. 5) There could be other classes that need to be incorporated...
8. BlackjackSolitaireStart should be something like this:
private class BlackjackSolitaireStart {
public static void main(String[] args) {
BlackjackSolitaire bj = new BlackjackSolitaire();
bj.play();
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started