Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Remember the childhood game Rock, Paper, Scissors? It is a two-player game in which each person simultaneously chooses either rock, paper, or scissors. The rules

Remember the childhood game Rock, Paper, Scissors? It is a two-player game in which each person simultaneously chooses either rock, paper, or scissors. The rules are:

  • Rock beats scissors but loses to paper
  • Paper beats rock but loses to scissors
  • Scissors beats paper but loses to rock

Write the code to create the game. Name your class "RockPaperScissorsYourLastName.java". Prompt player 1 and player 2 to each enter a string: rock, paper, or scissors. Pass those values to a method you create to determine the winner and return a winner.

Plan your code so that if they input with capitals, the game will still play.

Use a nested if statement to determine the winner (not AND or OR statements in the condition of your if statements). Set the winner in your if statement. DO NOT PRINT THE WINNER FROM THIS IF STATEMENT. You should use this if statement just SET the winner. Keep your view separate from the logic of this if statement. Print the winner from the main method.

Use efficient if statements. Remember: you don't have to check every possible situation.

Write a test to test your method

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

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions