(Solved) : Objectives Use Static Methods Static Fields Use Method Call Return Mechanism Use Random Nu Q41394755 . . .

Written in Java

Objectives Use the static methods and static fields. Use the method-call/return mechanism. Use the random-number generation O

1 package com.tamu.csci428; 2 3e import java.util.Random; 4 import java.util.Scanner; 6 public class RPS { 7 static int score

Select Mode : Enter 1 for Computer vs Computer, Enter 2 for User vs Computer 2 Select 1.Rock 2.Paper 3.Scissors 1 User won! Y

Objectives Use the static methods and static fields. Use the method-call/return mechanism. Use the random-number generation Overload methods. Problem Specification Write a program that lets a user play “Rock, Paper, Scissors” against the computer or computer against computer. In user-computer game, the program should ask the user to choose one of the three choices, and then the computer randomly picks one (without knowing what the user has chosen). For this problem, the user should be asked to enter an integer: 1 for rock, 2 for paper, 3 for scissors. Rock beats scissors, scissors beats paper, paper beats rock. The program should say who wins, and then keep playing until someone (the user or the computer) has won 5 rounds. The computer needs to keep track of the current score and should also display it before each round. In computer-computer game, play for 100 rounds and display which object won majority of the times. Design Specification Create Java class RPS. Create static variables for storing Score1 and Score2. Create a static method getRandom to get random integer between 1 and 3 Overload play method like in the below screenshot. Play() is for computer vs computer, play(userchoice) is for user vs computer. 1 package com.tamu.csci428; 2 3e import java.util.Random; 4 import java.util.Scanner; 6 public class RPS { 7 static int score1 = 0; static int score2 = 0; 10 static int get Random ( ) { 110 15 void play( {I 160 39 void play (int userChoice) { 404 53 int whoWon (int choice1, int choice2) { 54+ 93 94 124 public static void main(String [] args) { 125 126 Example: Your program should work for both modes. Mode 1 Select Mode : Enter 1 for Computer vs Computer, Enter 2 for User vs Computer 1 Computer1 Score 31 Computer2 Score 40 Computer2 won Mode 2: Select Mode : Enter 1 for Computer vs Computer, Enter 2 for User vs Computer 2 Select 1.Rock 2.Paper 3.Scissors 1 User won! Your choice 1 Computer choice 3 Your score : 1 Computer score : 0 Select 1.Rock 2.Paper 3.Scissors 2 ITS A TIE! Your choice 2 Computer choice 2 Your score : 1 Computer score : 0 Select 1.Rock 2.Paper 3.Scissors 3 User won! Your choice 3 Computer choice 2 Your score : 2 Computer score : 0 Select 1.Rock 2.Paper 3.Scissors 1 ITS A TIE! Your choice 1 Computer choice 1 Your score : 2 Computer score : 0 Select 1.Rock 2.Paper 3.Scissors 2 User won! Your choice 2 Computer choice 1 Your score : 3 Computer score : 0 Total number of games = 5 You won Show transcribed image text Objectives Use the static methods and static fields. Use the method-call/return mechanism. Use the random-number generation Overload methods. Problem Specification Write a program that lets a user play “Rock, Paper, Scissors” against the computer or computer against computer. In user-computer game, the program should ask the user to choose one of the three choices, and then the computer randomly picks one (without knowing what the user has chosen). For this problem, the user should be asked to enter an integer: 1 for rock, 2 for paper, 3 for scissors. Rock beats scissors, scissors beats paper, paper beats rock. The program should say who wins, and then keep playing until someone (the user or the computer) has won 5 rounds. The computer needs to keep track of the current score and should also display it before each round. In computer-computer game, play for 100 rounds and display which object won majority of the times. Design Specification Create Java class RPS. Create static variables for storing Score1 and Score2. Create a static method getRandom to get random integer between 1 and 3 Overload play method like in the below screenshot. Play() is for computer vs computer, play(userchoice) is for user vs computer.
1 package com.tamu.csci428; 2 3e import java.util.Random; 4 import java.util.Scanner; 6 public class RPS { 7 static int score1 = 0; static int score2 = 0; 10 static int get Random ( ) { 110 15 void play( {I 160 39 void play (int userChoice) { 404 53 int whoWon (int choice1, int choice2) { 54+ 93 94 124 public static void main(String [] args) { 125 126 Example: Your program should work for both modes. Mode 1 Select Mode : Enter 1 for Computer vs Computer, Enter 2 for User vs Computer 1 Computer1 Score 31 Computer2 Score 40 Computer2 won Mode 2:
Select Mode : Enter 1 for Computer vs Computer, Enter 2 for User vs Computer 2 Select 1.Rock 2.Paper 3.Scissors 1 User won! Your choice 1 Computer choice 3 Your score : 1 Computer score : 0 Select 1.Rock 2.Paper 3.Scissors 2 ITS A TIE! Your choice 2 Computer choice 2 Your score : 1 Computer score : 0 Select 1.Rock 2.Paper 3.Scissors 3 User won! Your choice 3 Computer choice 2 Your score : 2 Computer score : 0 Select 1.Rock 2.Paper 3.Scissors 1 ITS A TIE! Your choice 1 Computer choice 1 Your score : 2 Computer score : 0 Select 1.Rock 2.Paper 3.Scissors 2 User won! Your choice 2 Computer choice 1 Your score : 3 Computer score : 0 Total number of games = 5 You won

Expert Answer


Answer to Objectives Use the static methods and static fields. Use the method-call/return mechanism. Use the random-number generat…