Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED BY DRJAVA PROGRAM Advanced Rock Paper Scissors Game Objective Write one interface and three classes which will make a rock paper scissors game.

I NEED BY DRJAVA PROGRAM image text in transcribed
image text in transcribed
Advanced Rock Paper Scissors Game Objective Write one interface and three classes which will make a rock paper scissors game. First download the driver. The interface named RPSPlayerInterface will have the following methods . public int getPointsO public String getGesture0 * public void setPoints(int aPoints) e public void setGesture(String aGesture) public void chooseGesture0 The next class RPSPlayer implements this interface . It has an instance variable gesture which is a string that corresponds to rock". "paper", or scissors" * It has another instance variable points that keeps track of how many times the player has won . Create only a default constructor that sets the gesture to "none" and points to 0 e Create the accessors and mutators for the instance varaibles o The mutator for setGesture should make sure it is either "rock", "paper", or "scissors" If it is not then el the user that was a wrong choice and set gesture to "none" Write the chooseGesture method o In this case just set the instance variable gesture to "none Next write the class RPSHuman Player which inherits from RPSPlayer e It has an instance variable keyboard which is of type Scanner o Make sure to import java.util.Scanner .Create a default constructor Calls the parent's default constructor oSets up the keyboard to System.in e Override the method chooseGesture o Call the parent's setGesture method and pass the string gotten from the Scanner keyboard o You do not have to prompt the user. Next write the class RPSComputerPlayer which also inherits from RPSPlayer . It has an instance variable rand which is of type Random o Make sure to import java.util.Random . Create a default constructor o Calls the parent's default constructor o Constructs the rand variable Override the method chooseGesture o Using the random variable it should randomly select a number o Correspond the number to a string which wll either rock, paper, or scissors For instance if rand equals 0 then is a rock, else if 1 then paper, else if 2 then scissoTS o Use the parent's setGesture to then assign the randomly picked gesture

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

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago