Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this problem, youll play a simple rock, paper, scissors game. First, youll ask the user to pick rock, paper, or scissors. Then, youll have

In this problem, youll play a simple rock, paper, scissors game. First, youll ask the user to pick rock, paper, or scissors.

Then, youll have the computer randomly choose one of the options.

After that, print out the winner! You should keep playing the game until the user hits enter.

Note: Youll need to implement a method called String getWinner(String user, String computer). Luckily, you just wrote that in an earlier program!

Here is a sample run of the program.

Enter your choice (rock, paper, or scissors):rock User: rock Computer: paper Computer wins! Enter your choice (rock, paper, or scissors):paper User: paper Computer: scissors Computer wins! Enter your choice (rock, paper, or scissors):scissors User: scissors Computer: paper User wins! Enter your choice (rock, paper, or scissors):rock User: rock Computer: rock Tie Enter your choice (rock, paper, or scissors): Thanks for playing!

public class RockPaperScissors extends ConsoleProgram { private static final String USER_PLAYER = "User wins!"; private static final String COMPUTER_PLAYER = "Computer wins!"; private static final String TIE = "Tie"; private String getWinner(String user, String computer) {

} public void run() { } }

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

Students also viewed these Databases questions

Question

How can the Internet be helpful in a job search? (Objective 2)

Answered: 1 week ago