Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Determine the amplitude and period of each function.

Answered: 1 week ago