Question: write a psychic game program in which a player guesses a number randomly generated by a computer. For this project, we need 3 classes, Player,
write a psychic game program in which a player guesses a number randomly generated by a
computer. For this project, we need 3 classes, Player, PsychicGame, and Driver. Description for each
class is as following:
Project Folder Name: LB05
1. Player class
a.
Input
-
nickName
: nick name of the player
-
guessedNumber
: a number picked for the player will be assigned randomly by a
computer later.
b. Process
- constructor: asks a user players
nickName
using standard input, and initialize
guessedNumber
by 0.
-
getNickName()
: returns
nickname
.
-
getGuessedNumber()
: returns
guessedNumber
.
-
play
: get a computer-generated random number among 1 through 6, then display the
message,
nickname
has picked the number
guessedNumber
using standard output.
c.
Output
2. PsychicGame class
a.
Input
-
p1
: an object from Player class.
-
originalNumber
: a number generated randomly by a computer will be compared to a
guessedNumber generated by a player.
b. Process
- constructor: initialize an object of Player class, then initialize the
originalNumber
as 0.
-
play
: assign a computer-generated random number from 1 to 6 to the
originalNumber
,
display a message, The computer has chosen the number
originalNumber
, lets the
Player class object pick its number, then compare these two numbers. If the numbers
are matched, then display a message,
players nickname
has won., or No one has
won this time.
c.
Output
3. Driver class
This is the driver class which runs this application by the
main
method. However, at the very
beginning, please display a header mentioning whose psychic game is by standard output.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
