Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to find a way to create the three different classes for this practice. Create an application with the following three classes: class Player

I need to find a way to create the three different classes for this practice.

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

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago