Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program to simulate Blackjack. the rules of the game: a. There is one deck of cards b. Cards are drawn randomly using

Write a Java program to simulate Blackjack. the rules of the game:

a. There is one deck of cards

b. Cards are drawn randomly using Shuffle() method

c. The value of a hand is computed by adding the values of the cards in hand

d. The value of a numeric card such as four 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 fourth 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 its random number

j. You dont need to re-shuffle the remaining cards 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 user if it is 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 together, and within 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

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

Step: 3

blur-text-image

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

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions