If the number on two of the players'' four cards

Assignment Help JAVA Programming
Reference no: EM13163958

You are to develop a program to play a variation on a game of chance called single player Poker.

Game Description:

There is a Player who starts with 100 chips, each worth $1.00.

There is a deck of 36 cards:

{ Each card has a number in the range of [1, 9] printed on it - 9 possible values / cards.

{ There are 4 identical copies of each possible value / card - 36 cards in all.

{ Before each hand is dealt a new deck is opened and shued.

A Dealer asks the Player to place a bet, the Player can bet anywhere from one to as many chips as

they have.

The Dealer gets a new deck and shues it. This will be done by choosing two cards from the new

deck (at random positions) and swapping their locatiions.

The Dealer then deals a hand to the player, by giving the player 4 cards selected sequentially from

the shued deck described above.

A determination is then made as to whether the Player has won or lost as such:

1. 4 of a kind

If the number on each of the players' four cards is the same then the player gets their bet back

and in addition wins 6545 chips for each chip that was placed in that bet.

2. 3 of a kind

If the number on exactly three of the players' four cards is the same then the player gets their

bet back and in addition wins 51 chips for each chip that was placed in that bet.

3. Straight

If the number on the players' four cards can be arranged so that they form a consecutive 4

number sequence then the player gets their bet back and in addition wins 38 chips for each chip

that was placed in that bet.

4. Two Pair

If the number on two of the players' four cards is the same and the number on the remaining

two cards is also the same yet the number on all four cards in not the same then the player gets

their bet back and in addition wins 22 chips for each chip that was placed in that bet.

5. Pair - 2 of a kind

If the number on exactly two of the players' four cards is the same and the number on the

remaining two cards are dierent then the player gets their bet back and in addition wins 1 chip

for each chip that was placed in that bet.

6. Bubkiss

If the players' cards do not constitute one of the above ve hands then the player losses - does

not get their bet back.

A report of the players' new chip total is made.

This process repeats as long as the Player still has any chips and wishes to play.

A nal report stateing:

1. How many hands the Player played.

2. How bets the Player won.

3. How bets the Player lost.

4. The net winnings (or net losings) of the Player - Based o of starting with 100 chips.

Rules and Requirements:

All user input must be validated.

You must represent the deck of cards using an Array of ints (of size 36).

You must represent the players hand using an Array of ints (of size 4).

The following method denition is being provided for you to be called in your dealHand() method

below:

public static void sortHand(int[] hand)

{

for (int i = 0; i < hand.length; ++i)

{

int maxLoc = i;

for (int j = i+1; j < hand.length; ++j)

if (hand[j] > hand[maxLoc])

maxLoc = j;

int tmp = hand[i];

hand[i] = hand[maxLoc];

hand[maxLoc] = tmp;

}

}

For each of the following headings / descriptions, write and use a method that adheres to it:

{ public static void initDeck(int[] deck)

Assign the elements of deck the values 1 to 9 four times, consecutively - lling the array.

{ public static void shuffleDeck(int[] deck, int n)

The following is performed exactly n times:

Generate two random numbers (index1, index2) in the range 0 to 35 inclusive and then swap

the value of array element at index1 with the value of the array element at index2

{ public static void dealHand(int [] deck, int[] hand)

Initialize deck - initDeck()

Shue deck - shuffleDeck()

Uses the rst four values in deck to assign the four values of hand

Sort hand - sortHand()

{ public static void displayHand(int[] hand)

Prints the cards of hand in some reasonable report format.

{ public static boolean isQuad(int[] hand)

Returns true if and only if the cards in hand qualify as 4 of a kind, returns false otherwise.

{ public static boolean isTrip(int[] hand)

Returns true if and only if the cards in hand qualify as 3 of a kind, returns false otherwise.

{ public static boolean isStraight(int[] hand)

Returns true if and only if the cards in hand qualify as a straight, returns false otherwise.

{ public static boolean is2Pair(int[] hand)

Returns true if and only if the cards in hand qualify as two pair, returns false otherwise.

{ public static boolean isPair(int[] hand)

Returns true if and only if the cards in hand qualify as a pair, returns false otherwise.

Notes and Hint:

1. Read the user's option(s) as a String.

2. Use the String classes' equalsIgnoreCase method for comparisons.

3. Consider sorting the hand Array, to make your "is" methods easier to write.

Sample run(s):

Welcome to 4 Card Poker

Your initial bank roll is $100.00

++++++++++++++++++++++++++++++++++++++++++++++

Do you want to play a game? y

Place your bet [1, 100] : 101

Place your bet [1, 100] : 0

Place your bet [1, 100] : 2

Let the cards fall where they may ...

1 1 2 2

Let's get things in order ...

2 2 1 1

Congrats: You got 2 Pair and have won $44.

Do you want to play a game? y

Place your bet [1, 144] : 20

Let the cards fall where they may ...

9 1 9 7

Let's get things in order ...

9 9 7 1

Congrats: You got a Pair and have won $20.

Do you want to play a game? y

Place your bet [1, 164] : 100

Let the cards fall where they may ...

5 7 1 9

Let's get things in order ...

9 7 5 1

Sorry: you got Bubkiss and have lost $100.

Do you want to play a game? y

Place your bet [1, 64] : 64

Let the cards fall where they may ...

8 2 6 9

Let's get things in order ...

9 8 6 2

Sorry: you got Bubkiss and have lost $64.

+++++++++++++++++++++++++++++++++++++++++++

Party's Over:you are out of chips.

Thanks for playing ...

You played a total of 4 hands.

Of which, you won 2.

And you lost 2.

But in the end you lost $100.

Reference no: EM13163958

Questions Cloud

Calculate the expected ph of the buffer solutions : Given that the pKa for Acetic Acid is 4.77, calculate the expected pH of the buffer solutions using the Henderson-Hasselbalch equation and the concentrations of Acetic Acid and Acetate added to the 250 ml Erlenmeyer flask.
State what is the surrounding : What is the system? What is the surrounding? In what direction does the heat flow? Is the process endothermic or exothermic?
What is the composition of the mixture by volume : A gas mixture composed of helium and argon has a density of 0.605g/L at a 741mmHg and 298K .What is the composition of the mixture by volume?
Study the code and implement the operator overloading : The Table Q3 on the next page is the code of a class named Circle. Study the code and implement the operator overloading for these relational operators ( , >=) for the Circle class. Then, write a test program that creates two instances of the Circle ..
If the number on two of the players'' four cards : If the number on two of the players' four cards is the same and the number on the remaining two cards is also the same yet the number on all four cards in not the same then the player gets their bet back and in addition wins 22 chips for each chip th..
Calculate the concentration of iron in a dilutedsolution : Calculate the concentration (molarity) of iron in a dilutedsolution if 5.00 mL of 5.0x10^-4 M Fe(NH4)2(SO4)2 6H2O isdiluted with water to 100.0 mL.
Calculate the equilibrium constant of reversible reaction : When one mole of hydrogen iodide(HI) is stored in a 1-liter container at 444 oC, 22 % of HI wil be dissociated at equilibirum. Calculate the equilibrium constant of the reversible reaction of hydrogen iodide (HI)at 444 oC.
State acidity has affected many lakes in northern europe : This acidity has affected many lakes in northern Europe, the northern United States, and Canada, reducing fish populations and affecting other parts of the ecological network within the lakes and surrounding forests
State acid catalyzed hydrolysis of esters is usually better : acid catalyzed hydrolysis of esters is usually better than base catalyzed hydrolysis. True or False.............2. Borane selectively reduces a carboxylic acid while it leaves an ester alone.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java program for line item application

This exercise explains you the process of testing and enhancing Line Item application. Open LineItemApp, Validator, Product, LineItem, and ProductDB classes that are in the c:java1.6ch06LineItem directory and review this code.

  Write a program that reads in a list of numbers from a file

write a program that reads in a list of numbers from a file and adds up all those numbers. You may hard code in the name of the file, allowing the user to input the filename is not required

  Create your own date class

You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program:

  Minimal spanning tree decreasing edge dismissal

Minimal Spanning Tree Decreasing Edge Dismissal, Reverse-delete algorithm. Develop an implementation that computes the MST

  Write function in javascript to compute person-s gross pay

Write the function using JavaScript syntax to compute a person's gross pay for a week. The function should receive the number of hours worked and the rate of pay per hour.

  Write java program to reverse contents of original array

Write down the Java program method named reversal which returns the new array which is a reversal of original array. Use [5.0, 4.4, 1.9, 2.9, 3.4, 3.5] to test method.

  Java program to read line of text which ends with period

Write down the java program which will read the line of text which ends with the period, which serves as sentinel value. Show all the letters which occur in the text.

  Creating the gui for the game interface

A GUI-based application that allows a user to play a simple trivia game

  An elementary calculation yields the result

An elementary calculation yields the result that theoretically, the probability of turning up 7 when two dice are thrown is 1/6, or .166666. But what if more dice are thrown? If 3 dice are thrown, what is the probability that some 2 of three sum to 7..

  Create file lab7.java with a main method.

Create file Lab7.java with a main method. Inside your main method, write a segment of code which instantiates an object of the Student class (This class has been created for you in the  Student.java  file that is provided as part of this lab).

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Write a java applet for grade of gas in costco gas station

Write a java applet (not a java application program) for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you want to use.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd