|
|
|
|
|
|
|
|
import java.util.Scanner; |
|
|
|
|
|
import java.util.Random; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
public class RockPaperScissors { |
|
|
public class RockPaperScissors { |
|
|
static int computerScore = 0; |
|
|
|
|
|
static int playerScore = 0; |
|
|
|
|
|
|
|
|
int computerScore = 0; |
|
|
|
|
|
int playerScore = 0; |
|
|
|
|
|
|
|
|
public static void runGame() { |
|
|
|
|
|
|
|
|
public void runGame() { |
|
|
int computerInput = letComputerChoose(); |
|
|
int computerInput = letComputerChoose(); |
|
|
int userInput = letUserInput(); |
|
|
int userInput = letUserInput(); |
|
|
convertToWordUser(userInput); |
|
|
convertToWordUser(userInput); |
|
|
|
|
|
|
|
|
checkResults(computerInput, userInput); |
|
|
checkResults(computerInput, userInput); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void checkResults(int computerInput, int userInput) { |
|
|
|
|
|
|
|
|
public void checkResults(int computerInput, int userInput) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (computerInput == userInput) { |
|
|
if (computerInput == userInput) { |
|
|
|
|
|
|
|
|
return userInputWord; |
|
|
return userInputWord; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static String convertToWordComputer(int computerInput) { |
|
|
|
|
|
|
|
|
public String convertToWordComputer(int computerInput) { |
|
|
String computerInputWord = ""; |
|
|
String computerInputWord = ""; |
|
|
|
|
|
|
|
|
if (computerInput == 1) { |
|
|
if (computerInput == 1) { |
|
|
|
|
|
|
|
|
return computerInputWord; |
|
|
return computerInputWord; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static int letUserInput() { |
|
|
|
|
|
|
|
|
public int letUserInput() { |
|
|
int userInput; |
|
|
int userInput; |
|
|
Scanner input = new Scanner (System.in); |
|
|
Scanner input = new Scanner (System.in); |
|
|
System.out.println("1 for Rock, 2 for Paper, 3 for Scissors: "); |
|
|
System.out.println("1 for Rock, 2 for Paper, 3 for Scissors: "); |
|
|
|
|
|
|
|
|
return userInput; |
|
|
return userInput; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static int letComputerChoose() { |
|
|
|
|
|
|
|
|
public int letComputerChoose() { |
|
|
Random rgen = new Random(); |
|
|
Random rgen = new Random(); |
|
|
int computerInput = rgen.nextInt(1,4); |
|
|
int computerInput = rgen.nextInt(1,4); |
|
|
return computerInput; |
|
|
return computerInput; |