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)
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.
package rpsgamesimulation; import java.util.Random; import java.util.Scanner; /** * * @author cristy */ public class RPSGame {...
(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 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 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...
Write a program in python that lets the user play the game 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. 2 corresponds to paper, and 3 corresponds to scissors. To set up the random number library, write the following at the top of your code: import random random.seed(300) Use...
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....
(c++ only)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, the user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard using a menu in a function, userChoice, that returns a character. Next, there should be a function, computerChoice, that generates the computer’s play. A random number in the range of 1 through 3 is generated. If the...
i have created a program for a game of rock, paper, scissors but i must make it run more than once in some kind of loop. i want to add a function named runGame that will control the flow of a single game. The main function will be used to determine which game mode to initiate or exit program in Player vs. Computer, the user will be asked to enter their name and specify the number of rounds for this...
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, 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 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...