Question: Java program to simulate BlackJack. The rules; a.There is one deck of playing cards. b.Cards are drawn randomly (Shuffle() method). c.The value of a hand
Java program to simulate BlackJack. The rules;
a.There is one deck of playing cards.
b.Cards are drawn randomly (Shuffle() method).
c.The value of a hand is computed by adding the values of the cards in the hand.
d.The value of numeric card such as five is its numerical value.
e.The value of a face card is 10.
f.Ace is either 1 or 11.
g.Ace is 11 unless it puts the total value of the hand over 21.
h.Second, third or forth Ace are all counted as 1.
i.Generate a random number between 16-21. Keep drawing as many cards (AddCard() method) as needed until the total value of the hand is equal or greater than this random number.
j.You don't need to re-shuffle the remaining crads after each drawing.
k.You should have a class Hand, in which you compute and return the value of a hand based on the above rules.
l.You should have a "public class BlackjackHand extends Hand", which notifies the users if it a Blackjack (only two cards are drawn with the total value of 21).
m. Log all drawn cards and the total value of a hand.
n.Sort the cards in the hand so that cards of the same suit are grouped togther, and witin a suit the cards are sorted by value. Cards are sorted into order of increasing value. Note that aces are considered to have the lowest value.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
