Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify your Rock Paper Scissor Lizard Spock game from Week 6 to generate a random number for Player 2, use the random number to assign

Modify your Rock Paper Scissor Lizard Spock game from Week 6 to generate a random number for Player 2, use the random number to assign it a string selection (rock paper scissor lizard spock) and assign that as Player 2's choice. Complete the work of assigning Player 2's random choice in a method. It should take no parameters but return a string that represents Player 2's random choice. The implementation should use the Random class to get your random number.

Now you are only getting a choice from player one and playing until they enter done using the sentinel value loop. The rest of your program should stay the same. You can use your program with the nested if statements or the switch statement.

Verify that your file still works with your testing file. If Lizard and Spock are not implemented, verify that those tests are added. Make sure all your tests are exhaustive (uppercase, funky case, same plays, all options, bad input). Note: you do not need to test your random player 2 option method. After all, how could you? (The answer is not easily; therefore, you do not need to test it - just your determine who the winner is method.)

Create a program called RandomNumbers. Ask the user how many random numbers they would like to see. Ask the user to provide the lowest number they would like to use and the highest number. Only return integers between those two numbers.

FYI : Lizard and Spock has not been added in this yet. It should be able to read rock, paper, scissors , Lizard, and Spock for the options. Lizard beat rock, paper, scissors and Spock beats all.

image text in transcribed

import java.util.Scanner; public class RockPaperScissorsBurt { public static void main(String[] args) { Scanner pick = new Scanner(System.in); int al = -1; int a2 = -1; String s1 = String s2 = System.out.println("Player 1: Choose rock, scissors, or paper:"); s1 = pick.next(); s1 = s1.toLowerCase(); if (s1.equals("rock")) { al = 0; } else if (s1.equals("scissors")) { al = 1; } else if (s1.equals("paper")) { al = 2; } System.out.println("Player 2: Choose rock, scissors, or paper:"); pick.next(); 52 = 52.toLowerCase(); if ($2.equals("rock")) { a2 = 0; } else if (s2.equals("scissors")) { a2 = 1; } else if (s2.equals("paper")) { a2 = 2; } a2) { System.out.println("It's a draw! You both chose the same object" + which is: + 51 + "."); } else if ((al == 2 && a2 == 1 && al

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago