Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Java, create a GUI based two player dice game call Chicago that uses two d

ID: 3815090 • Letter: U

Question

Using Java, create a GUI based two player dice game call Chicago that uses two dice to play. The user will be one player and the computer will be the second player.

To Play: There are eleven rounds numbered 2 -12. In each round the player tries to roll and score the number of the round, the numbers being the combinations possible with 2 dice. Note: Use JPG image of a dice only two dice that will show 2-12 on a dice for player and the computer.

If a player throws the correct number for that round they score 1 point. If they throw any other number they don’t score. The highest total after 20 rounds wins the game.

- Complete rules are displayed in an easy to read manner at the beginning of the game.

- Game has an appealing layout and game play is easy to follow in GUI.

- Game follows rules as described at beginning of the game.

- Game uses an object oriented approach and game uses structured code in methods and main().

-Game is playable in 10 minutes or less and game provides complete interaction between player and computer.

Explanation / Answer

GAMES WITH TWO DICE:

A simple but exciting game, with an unusual way of keeping ”score”. For 2–6 players.

You will in addition to the two dice need one extra die per player (or keep score using

coins or paper and pencil).

Aim of the game: To be the only player left in the game, after all the others have been

forced out due to rolling low combinations.

How to play: Each player places the extra die before him or her on the table, with the

’6’ face up. Decide who starts; the turn order then proceeds clockwise.

You play several rounds, and in each round the player with the lowest combination

loses a ”life” – shown by his die being rotated to the next lower number. Everyone thus

starts with 6 lives. If your die goes down to 0, you are out of the game.

When it is your turn, you roll both dice in the middle of the table. If you are not

satisfied with the result you may re-roll, and if you wish re-roll a second and final time. If

you choose to re-roll you must do so with both dice – it is not permitted to keep one and

re-roll the other.

The highest possible throw is ”Mexico”: 2-1.

Ranking just below Mexico are the pairs: 6-6 is the highest pair, and 1-1 is the

lowest.

Ranking below the pairs are two different numbers on the dice, with the highest

always being the decider and mentioned first: 6-5 is the highest combination here,

followed by 6-4, 6-3, 6-2, 6-1, 5-4, 5-3 and so on all the way down to 3-1 which is the

lowest possible throw.

When all players have rolled according to the above rules, the player who made the

lowest result loses the round and one ”life”. Example: On the first round A rolled 5-4, B

rolled 2-2, C rolled 6-1 and D rolled 4-4. Player A has made the lowest roll and loses one

life, turning his extra die so that it shows 5 instead of 6.

If two or more players are equally low, they lose one life each. Special rule:

Whenever a Mexico (or several) is rolled in the round, the loser loses two of his

remaining lifes!

When you are down to 0 you are out of the game. The last remaining player is of

course the winner. If two or more players are left in the game, with 1 life each

remaining, and they all lose the round because of a tie on the dice results, a ”dead

game” without a winner is declared.

Dice game:

The dice game Chicago has eleven rounds numbered 2 -12. In each round, the player tries to

roll and score the number of the round, the numbers being the possible combinations with 2

dice.

If a player throws the correct number for that round they score 1 point (e.g., if they roll a 4

and a 2 for round 6, they score a point). If they throw any other number they don’t score (e.g.

if they roll a 5 and a 3 for round 10, they do NOT score a point). The highest total after 11

rounds wins the game. If there is a tie for the highest score, then a winner cannot be

determined.

Method play:

Return value: int (the number of points to add to the player’s score: 0 or 1)

Method name: play

Parameter list: one parameter – an integer representing the round number (i.e. int

roundNumber)

Algorithm: (determine number of points to add to current score)

-If the sum of FaceValue1 and FaceValue2 is equal to the roundNumber return 1

(a point is given)

-Otherwise, return 0 (no point is given)

Method winner:

-Return value: int (the number of the player who has the greatest score: 1, 2, 3, 4 for

player 1, player 2, player 3, and player 4, respectively. Return 0 if no player can be

determined)

-Method name: winner

-Parameter List: four parameters – four integers, one for each player's score

-Algorithm: determine which player number has won. The score must be greater than

all the other scores, NOT greater than or equal. For example, who wins if the following

is true?

Algorithm:

Create a for- loop that will iterate from 2 to 12 (the round number)

For each player, you will need to roll the dice and play this round by calling the

appropriate methods in Chicago. You will have 8 statements in this for-loop, 2

for each player. Also, remember to use your compound assignment operator.

Once rounds 2 through 12 are completed, call Chicago's winner method with

the four players' scores. The value returned is the player number of the winning

player. Note that if there’s a tie for the high score, then no winner is determined.

import java.util.*;

public class PlayChicago

{

public static void main(String [ ] args)

{

//Declare variables and instantiate objects

Chicago player1 = new Chicago();

Chicago player2 = new Chicago();

Chicago player3 = new Chicago();

Chicago player4 = new Chicago();

int p1=0, p2=0, p3=0, p4=0;

int playerWinner;

final int ROLLS = 6;

Die die1 = new Die();

Die die2 = new Die();

// Play Chicago

for(int roll = 1; roll <=ROLLS; roll++)

{

num1 = die1.roll();

num2 = die2.roll();

// Determine the winner

// Output the winner and scores

System.out.println("Player 1's score: " + p1 +

" Player 2's score: " + p2 +

" Player 3's score: " + p3 +

" Player 4's score: " + p4 + " ");

if (playerWinner == 0)

System.out.println("A winner could not be determined");

else

System.out.println("Player " + playerWinner + " won!");

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote