Question: Create an application with the following three classes: class Player // put it in a package called playerspackage class GuessGame // put it in a

Create an application with the following three classes:

class Player // put it in a package called playerspackage

class GuessGame // put it in a package called guessgamepackage

class GameLauncher // put it in the package guessgamepackage

Class GameLauncher has its own main method and will instantiate a GuessGame object.

Class GuessGame creates two Player objects, create an integer number between 50 and 90, then asks each player to guess the integer number it has created. After that the GuessGame class checks the result, and either prints out information about the winning player(s) or asks them to guess again. The game terminates when at least one player guesses the right number. Assume that the Players are very smart, which means that they will not guess the same number twice or guess a number that has been guessed by the other player.

Here is an example of a possible output

I have a number between 50 and 90, guess the number?

Player 1: I am guessing 53

Player 2: I am guessing 55

No winners: Please try again

Player 1: I am guessing 67

Player 2: I am guessing 87

Great, we have a winner!

My number is 87, so Player 2 wins!

Hints:

Use Math.random() method to generate random numbers between 0 and 1.

Then use

50 + (int) (Math.random() * 40)

to generate a random number between 50 and 90.

Use ArrayList objects as a memory for each player.

For example: ArrayList myMemory = new ArrayList();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!