Question

package rpsgamesimulation; import java.util.Random; import java.util.Scanner; /** * * @author cristy */ public class RPSGame {...

package rpsgamesimulation;
import java.util.Random;
import java.util.Scanner;

/**
*
* @author cristy
*/
public class RPSGame
{
private String userChoice, computerChoice;
  
public RPSGame()
{
userChoice = "rock";
computerChoice = "rock";
}
  
public String getUserChoice()
{
return userChoice;
}
  
public String getComputerChoice()
{
return computerChoice;
}
  
public void setUserChoice(String aUserChoice)
{
userChoice = aUserChoice;
}
  
public void setComputerChoice(String aComputerChoice)
{
computerChoice = aComputerChoice;
}
  
public String toString()
{
return "User Choice: " + userChoice + " Computer Choice: " + computerChoice;
}
  
public void computerPlay()
{
Random myRan = new Random();
int numComputerChoice = myRan.nextInt(3);
//Write the if-statement that determines that the computer chose:
// Rock - if the random number generated was 0
// Paper - if the random number generated was 1
// Scissors - if the random number generated was 2
  
  
}
  
public void userPlay()
{
Scanner keyboard = new Scanner(System.in);
String strUserChoice;
System.out.println("What is your choice - Rock, Paper, or Scissors ?");
userChoice = keyboard.nextLine();
  
  
}
  
public void determineWinner()
{
//Write the switch statement that evaluated userChoice:
// The case of the user entering "rock"
// Check all the possible computer choices and print out who is the winner
// The case of the user entering "paper"
// Check all the possible computer choices and print out who is the winner
// The case of the user entering "scissors"
// Check all the possible computer choices and print out who is the winner
// The default case, where neither "rock," "paper," or "scissors" were selected by user
// Display an error message.
userChoice = userChoice.toLowerCase();
  
switch(userChoice)
  
  
  

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
package rpsgamesimulation; import java.util.Random; import java.util.Scanner; /** * * @author cristy */ public class RPSGame {...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • (C++) Hey guys we just went over loops and it got me confused, it has me...

    (C++) Hey guys we just went over loops and it got me confused, it has me scrathcing my head for the past two days. I would appreciate any help you guys have to offer. Few places I have a hard time is get input and determine winner(cummulative part). Write a program that lets the user play the Rock, Paper, Scissors game against the computer. The computer first chooses randomly between rock, paper and scissors, but does not display its choice....

  • IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors...

    IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet....

  • (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against...

    (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet. The...

  • SIMPLE: PSEUDOCODE FOR THE CODE BELOW Bingo.java package bingo; import java.util.Scanner; import java.util.Random; public class Bingo...

    SIMPLE: PSEUDOCODE FOR THE CODE BELOW Bingo.java package bingo; import java.util.Scanner; import java.util.Random; public class Bingo {        public static BingoCard gameCard;     public static int totalGamesWon = 0;        public static void main(String[] args) {               //Use do-while loop to do the following:         //1. instantiate a gameCard         //2. call the method playGame()         //3. call the method determineWinner()         //4. Ask user if they wish to play again? (1 = yes; 2 = no)...

  • In this problem, you’ll play a simple rock, paper, scissors game. First, you’ll ask the user...

    In this problem, you’ll play a simple rock, paper, scissors game. First, you’ll ask the user to pick rock, paper, or scissors. Then, you’ll 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: You’ll 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....

  • Python please. I have a working one that doesn't keep track of w/l ratio, it may...

    Python please. I have a working one that doesn't keep track of w/l ratio, it may be helpful to see how others did the entire program and inserted that module. Write a modular program that let the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 thru 3 is generated but do not display the computer choice immediately. Number 1...

  • Write a Python program (using python 3.7.2) that lets the user play the game of Rock,...

    Write a Python program (using python 3.7.2) that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’t display the...

  • Use Dev C++ for program and include all of the following. Im lost. Make sure the...

    Use Dev C++ for program and include all of the following. Im lost. Make sure the user enters a letter of R, P, or S and the computer generates a number between 0-2 and changes that number to a letter of R, P or S, using a switch. Make sure the user knows why he/she has won or lost – print a message like “Paper covers Rock” or “Scissors cuts Paper”. Ask the user how many times he/she wants to...

  • Can someone help me with my Java code error! Domain package challenge5race; import java.util.Random; public class...

    Can someone help me with my Java code error! Domain package challenge5race; import java.util.Random; public class Car {    private int year; private String model; private String make; int speed; public Car(int year, String model, String make, int speed) { this.year = year; this.model = model; this.make = make; this.speed = speed; } public Car() { } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public String getModel() { return model; }...

  • the RollDie.java: import java.util.Random; import java.util.Scanner; /* * HEADER HERE !! */ public class RollDie {...

    the RollDie.java: import java.util.Random; import java.util.Scanner; /* * HEADER HERE !! */ public class RollDie { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); // Step 1: Declare and initialize array and // initialize random number generator int[] rollValueCounts = new int[7]; Random randGen = new Random(); // Step 2: Determine the number of rolls System.out.print("How many times do you want to roll the die?"); System.out.print(" [Max value is 100] "); int numRolls = scnr.nextInt(); // TODO:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT