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

  Design an adt for a two-color

Design an ADT for a two-color, double-stack ADT that consists of two stacks one "red" and one "blue" and has as its operations color-coded versions of the regular stack ADT operations.

  Write java application to show successive element of array

Write down java application named GoTooFar which declares the array of 5 integers and stored five values in array. write try block in which you loop to show each successive element of array.

  Regular expression that selects lines

Write a regular expression that selects lines containing the html BR tag. The rules for this tag are that, like all html tags, it starts with . In between are the letters b and r in that order

  Implement the application using a singly linked list

Implement the following application using a singly linked list. This application accepts from console and stores a list of 10 names of your friends in the singly linked list

  The game of pig

Write a program that allows a single player to practice the game (that is, there will be no opponent, just a single player). Play 5 turns in the game to get a total score for the player. Refer to the sample output below for a detailed example.

  Implement avl tree

Implement AVL trees that allows both iterative traversal and recursive traversal.

  Write a program that reads a set of floating-point

Write a program that reads a set of floating-point data values from the input.

  Write a java program called salesinfominer

Write a Java program called SalesInfoMiner that reads in a file of products, stored in text format. The program must then read in information about past sales transactions and output all the products to a new file, sorted by product description,..

  Creating the gui for the game interface

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

  Java program editing

Prompt the user for the student's score and put that value into an object

  supply a student tester class that tests all methods

Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply an appropriate constructor and methods getName( ), addQuiz(int score), getTotalScore( ), and getAverageScore ( ).

  Write a program to register students for a college

Students have names, addresses and courses. Implement the interface class RegisterStudent. RegisterStudent has one method, public boolean register, which returns the boolean value of true or false if the student is successfully registered for the ..

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