/home/caleb/ASDV-Java/MP2_CalebFontenot/src/main/java/com/calebfontenot/mp2_calebfontenot/RockPaperScissors.java |
package com.calebfontenot.mp2_calebfontenot;
public class RockPaperScissors {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.println("Rock, Paper, Scissors! Pick a number to continue.");
while (true) {
int computerNumber = (int) (Math.random() * 3);
System.out.print("scissors (0), rock (1), paper (2): ");
int userNumber = input.nextInt();
System.out.println("computer number: " + computerNumber);
switch (computerNumber) {
case 0:
if (userNumber == 0) {
System.out.print("The computer chose scissors. You also picked scissors. It's a draw!");
} else if (userNumber == 1) {
System.out.print("The computer chose scissors. You picked rock. You won!");
} else if (userNumber == 3) {
System.out.print("The computer chose scissors. You picked paper. You lost.");
}
break;
case 1:
if (userNumber == 0) {
System.out.print("The computer chose rock. You chose scissors. You lost.");
} else if (userNumber == 1) {
System.out.print("The computer chose rock. You also picked rock. It's a draw!");
} else if (userNumber == 3) {
System.out.print("The computer chose rock. You picked paper. You won!");
}
break;
case 2:
if (userNumber == 0) {
System.out.print("The computer chose paper. You picked scissors. You won!");
} else if (userNumber == 1) {
System.out.print("The computer chose paper. You picked rock. You lost.");
} else if (userNumber == 3) {
System.out.print("The computer chose paper. You also picked paper. It's a draw!");
}
break;
}
System.out.println("");
}
}
}