I am making a rock,paper,scissors,lizard,spock java program for one of my classes. Ive got it all done, except when I was testing it, I noticed choice 4 and 5(LIZARD and SPOCK) dont do anything unless its a tie. I dont see what is wrong with my code, so if someone else can see it and point it out to me, much appreciated! Here is my code:
import java.util.*; public class RockPaperScissors { private final static int ROCK = 1; private final static int PAPER = 2; private final static int SCISSORS = 3; private final static int LIZARD = 4; private final static int SPOCK = 5; public static void main(String[] args) { Random rand = new Random(); int userScore = 0; int computerScore = 0; int userPlay = 1; int computerPlay; Scanner key = new Scanner(System.in); System.out.println("Get ready to play the game of Rock, Paper," + "Scissors, Lizard, Spock!"); System.out.println("The Rules are as followed: "); System.out.println("User will choose their gesture and the computer will" + "choose a random gesture. Whoever wins gets a point!\n"); System.out.print("*Scissors cut Paper*\n" + "*Paper covers Rock*\n" + "*Rock crushes Lizard*\n" + "*Lizard poisons Spock*\n" + "*Spock melts Scissors*\n" + "*Scissors decapitate Lizard*\n" + "*Paper disproves Spock*\n" + "*Spock vaporizes Rock*" + "*Rock crushes Scissors*\n\n"); while (userPlay != 0) { System.out.println("Choose 0 if you want to quit the game."); System.out.println("Choose 1 for Rock, 2 for Paper, 3 for Sciscors, " + "4 for Lizard, or 5 for Spock"); userPlay = key.nextInt(); computerPlay = (rand.nextInt(5) + 1); //Users Choice of Gesture. if (userPlay == 1) { userPlay = ROCK; } else if (userPlay == 2) { userPlay = PAPER; } else if (userPlay == 3) { userPlay = SCISSORS; } else if (userPlay == 4) { userPlay = LIZARD; } else if (userPlay == 5) { userPlay = SPOCK; } //Computers choice of Gesture. if (computerPlay == 1) { computerPlay = ROCK; } else if (computerPlay == 2) { computerPlay = PAPER; } else if (computerPlay == 3) { computerPlay = SCISSORS; } else if (computerPlay == 4) { computerPlay = LIZARD; } else if (computerPlay == 5) { computerPlay = SPOCK; } if (computerPlay == ROCK && userPlay == SCISSORS) { System.out.println("You chose Scissors"); System.out.println("Computer chose Rock! You Lose\n\n"); computerScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == ROCK && userPlay == PAPER) { System.out.println("You chose Scissors"); System.out.println("Computer chose Rock you Win\n\n"); userScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == PAPER && userPlay == SCISSORS) { System.out.println("You chose Scissors"); System.out.println("Computer chose Scissor you Win\n\n"); userScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == PAPER && userPlay == ROCK) { System.out.println("You chose Rock"); System.out.println("Computer chose Paper you Lose\n\n"); computerScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == SCISSORS && userPlay == ROCK) { System.out.println("You chose Rock"); System.out.println("Computer chose Scissors you Win\n\n"); userScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == SCISSORS && userPlay == PAPER) { System.out.println("You chose Paper"); System.out.println("Computer chose Scissors you Lose\n\n"); computerScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == LIZARD && userPlay == ROCK) { System.out.println("You chose Rock"); System.out.println("Computer chose Lizard you Win\n\n"); userScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == LIZARD && userPlay == SPOCK) { System.out.println("You chose Spock"); System.out.println("Computer chose Lizard you Lose\n\n"); computerScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == LIZARD && userPlay == SCISSORS) { System.out.println("You chose Scissors"); System.out.println("Computer chose Lizard you Win\n\n"); userScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == LIZARD && userPlay == PAPER) { System.out.println("You chose Paper"); System.out.println("Computer chose Lizard you Lose\n\n"); computerScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == SPOCK && userPlay == ROCK) { System.out.println("You chose Rock"); System.out.println("Computer chose Spock you Lose\n\n"); computerScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == SPOCK && userPlay == PAPER) { System.out.println("You chose Paper"); System.out.println("Computer chose Spock you Win\n\n"); userScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == SPOCK && userPlay == SCISSORS) { System.out.println("You chose Scissors"); System.out.println("Computer chose Spock you Lose"); computerScore++; System.out.println("Current Score: " + computerScore + " to " + userScore + "\n\n"); } if (computerPlay == userPlay) { System.out.println("TIE"); } } if (userPlay == 0) { if (computerScore > userScore) { System.out.println("Computer wins. Final Score: " + computerScore + " to " + userScore); } else if (computerScore < userScore) { System.out.println("You beat the Computer! Final Score: " + userScore + " to " + computerScore); } else if (computerScore == userScore) { System.out.println("You Tied the Computer! Final Score: " + userScore + " to " + computerScore); } } } }