Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an object oriented program with the following classes JAVA. === Deck === The Deck class represents a standard 52-card deck; Ace high Each card

Write an object oriented program with the following classes JAVA.

=== Deck ===

The Deck class represents a standard 52-card deck; Ace high

Each card is in one of two states -- dealt (D) and not-yet-dealt (ND)

Cards are ordered. The D and ND cards each have their own order

When created, all 52 cards are ND, and are in order, by suit (clubs 2 through A, diamonds 2 through A, hearts 2 through A, spades 2 through A)

methods:

dealOne() -- moves the top card from ND to D and returns the card

print() -- prints non-dealt cards and dealt-cards (in order, as separate lists)

shuffle(goodness) -- goodness is a floating point number between 0 and 1.

Goodness of 0 is perfect shuffle (cards are in a completely random order). Goodness of 1 is no shuffling (deck is unchanged). As you change goodness from 0 to 1 the shuffle gets progressively worse. You can make up your own shuffle algorithm. Include a description of your shuffle algorithm in the README file.

=== Card ===

The Card class represents a single card

methods:

print() -- prints the type of card

=== Hand ===

The Hand class represents a set of cards. From 0 to 52 cards, total

Cards are always in a definite order

methods:

print() -- prints the hand (in order)

addCard(card) -- adds a card to the hand

sortBySuit() -- sorts the cards by suit, and then by value

sortByValue() -- sorts by value, then by suit

hasStraight(len, sameSuit) -- returns true if hand contains a straight of the given length. If sameSuit is true, counts only straight with cards in the same suit (flushes); If sameSuit if not true, any straight is counted. A "straight" is simply when you have cards of consecutive values. For ex: A 3-card straight with sameSuit = false. The three cards may be of different suits, and it still counts as a 3-card straight if there are more than three consecutive cards. This hand has a 3-card straight:

4 of clubs, 5 of spades, 6 of diamonds 7 of clubs, K of clubs

This hand does not:

4 of clubs, 5 of clubs, 7 of clubs, 8 of spades, K of clubs

Write a test program called CardDealer.java that takes three commandline arguments

for ex: java CardDealer 100 5 0.5

will run the following steps 100 times

1. Create a deck of cards

2. Shuffle using the goodness factor

3. Deal 5 hands (going in order player1, player2, ... player5, player1....etc)

4. Count the number of 3 card straights.

After 100 runs, compute the chances of getting a 3 card straight (this is defined as /). For this run total number of hands will be 500.

Run your program for goodness values of (0, 0.3, 0.5, 1, 0.9). Tabulate your results in the README file.

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions