Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Please answer without using arrays and try to also just use public static void main(String[] args) keep it simple and at a beginner's level

Java

Please answer without using arrays and try to also just use public static void main(String[] args)

keep it simple and at a beginner's level

Try to only use the main topics to make the program function

Main topics:

User validated input

if & if - else Statements

Loop Statements

Library Methods

Program Specification:

Write a program that allows a single Player (the user) to play a simple three dice game of chance against a single Opponent (the computer).

Game Description:

There is a single Player (human), with three dice.

There is a single Opponent (computer), with three dice.

Each die is 4 sided, and each of its sides is labeled with a unique number: 2, 3, 5 or 7.

When a die is rolled it stops with one of its sides facing down, we will call this the value of the die roll.

A game is made up of rounds, a single round is played as such:

1. The computer Opponent rolls its dice

2. The dice are displayed

3. The Player rolls their dice

4. The dice are displayed

5. A determination is made as to who won the round, this determination is made via the following rules:

A Triple is when all the dice have the same number on their top faces, the value of the Triple is this common value. A Pair is when exactly two of the dice have the same number on their top faces, the value of the pair is this common value.

A Straight is when the three dice values can be arranged into a consecutive sequence, there are exactly two possible Straights 2 3 5 in any order and 3 5 7 in any order.

Junk is anything that is not a Triple, a Pair or a Straight.

Larger values beat smaller values, same values are a tie.

Any Triple beats any Straight.

Any Triple beats any Pair.

Any Triple beats any Junk.

Two Triples are compared by their respective Triple values.

Any Straight beats any Pair.

Any Straight beats any Junk.

Any 3 5 7 Straight beats any 2 3 5 Straight.

Any Pair beats any Junk.

Two Pairs are first compared by their respective Pair values, and then by their respective non-common die values.

6. The result of the round (with respect to the Player) is announced.

7. The result of the round (with respect to the Player) is tallied, by increasing the number of player wins, ties, or loses by one.

The player is asked if they wish to play another round.

When the game is over, the results of the game are announced: how many rounds the player played; how many they won; how many they tied; how many they lost.

Notes:

All user input must be validated (user validation loop) in a reasonable manner.

Grading:

Performance Indicator [1] [2] [3]

Readability and documentation 0 1 1

Use of library methods 1 2 2

Use of programmer defined methods 1 2 2

Functional requirements 2 3 4

Efficiency 0 1 1

Sample run(s):

Welcome to opponent Dice

---------------------------------------------------------

You will be playing dice against the opponent

High beats low, and same ties

Triples beat Straights, Pairs and Junk Straights beat Pairs and Junk

Pairs beat Junk In the case of two identical Pairs - high card decides

in the case of two Nothings - its a tie

---------------------------------------------------------

Player

------------

7 7 5

opponent

------------

3 3 3

Sorry, you lose!

Do you wish to play again [y, n] : y

Player

------------

3 2 5

opponent

------------

2 2 7

Congrats, you win!

Do you wish to play again [y, n] : y

Player

------------

5 5 3

opponent

------------

2 7 5

Congrats, you win!

Do you wish to play again [y, n] : y

Player

------------

7 2 7

opponent

------------

2 7 2

Congrats, you win!

Do you wish to play again [y, n] : y

Player

------------

5 7 7

opponent

------------

5 3 7

Sorry, you lose! Do you wish to play again [y, n] : y

Player

------------

3 2 2

opponent

------------

3 2 3

Sorry, you lose! Do you wish to play again [y, n] : y

Player

------------

7 2 3

opponent

------------

2 2 2

Sorry, you lose! Do you wish to play again [y, n] : n

opponent Dice Results

---------------------

You played 7 rounds

Rounds won :3

Rounds tied :0

Rounds lost :4

---------------------

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

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions