Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- *
- *
- */
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String player1, player2, line;
- int actionP1, actionP2;
- Scanner kb = new Scanner(System.in);
- //Make sure statements are accurate to diagram!
- System.out.println("Player 1, please enter your name:");
- player1 = kb.nextLine();
- System.out.println("Player 2, please enter your name:");
- player2 = kb.nextLine();
- System.out.println(player1 + ", please enter your command:");
- line = kb.nextLine();
- actionP1 = Integer.parseInt(line);
- System.out.println(player2 + ", please enter your command:");
- line = kb.nextLine();
- if ((actionP1 > 5) || (actionP1 < 1)) {
- System.out.println("I'm sorry, this is not a valid command.");
- }else{
- actionP2 = Integer.parseInt(line);
- if ((actionP2 > 5) || (actionP2 < 1)) {
- System.out.println("I'm sorry, this is not a valid command.");
- }else{
- if ((actionP1 == 1) && (actionP2 == 2)) {
- System.out.println(player1 + " wins! Paper covers Rock.");
- } else if ((actionP1 == 2) && (actionP2 == 1)) {
- System.out.println(player2 + " wins! Paper covers Rock.");
- }
- if ((actionP1 == 1) && (actionP2 == 3)) {
- System.out.println(player1 + " wins! Paper disproves Spock.");
- } else if ((actionP1 == 3) && (actionP2 == 1)) {
- System.out.println(player2 + " wins! Paper disproves Spock.");
- }
- if ((actionP1 == 1) && (actionP2 == 5)) {
- System.out.println(player2 + " wins! Scissors cuts Paper.");
- } else if ((actionP2 == 1) && (actionP1 == 5)) {
- System.out.println(player1 + " wins! Scissors cuts Paper.");
- } else if ((actionP1 == 1) && (actionP2 == 4)) {
- System.out.println(player2 + " wins! Lizard eats Paper.");
- }
- if ((actionP1 == 4) && (actionP2 == 1)) {
- System.out.println(player1 + " wins! Lizard eats Paper.");
- }
- if ((actionP1 == 2) && (actionP2 == 3)) {
- System.out.println(player2 + " wins! Spock vaporizes Rock.");
- }
- if ((actionP2 == 2) && (actionP1 == 3)) {
- System.out.println(player1 + " wins! Spock vaporizes Rock.");
- } else if ((actionP1 == 2) && (actionP2 == 5)) {
- System.out.println(player1 + " wins! Rock crushes Scissors.");
- } else if ((actionP1 == 5) && (actionP2 == 2)) {
- System.out.println(player2 + " wins! Rock crushes Scissors.");
- }
- if ((actionP1 == 2) && (actionP2 == 4)) {
- System.out.println(player1 + " wins! Rock crushes Lizard.");
- } else if ((actionP1 == 4) && (actionP2 == 2)) {
- System.out.println(player2 + " wins! Rock crushes Lizard.");
- }
- if ((actionP1 == 4) && (actionP2 == 3)) {
- System.out.println(player1 + " wins! Lizard poisons Spock.");
- } else if ((actionP1 == 3) && (actionP2 == 4)) {
- System.out.println(player2 + " wins! Lizard poisons Spock.");
- }
- if ((actionP1 == 4) && (actionP2 == 5)) {
- System.out.println(player2 + " wins! Scissors decapitates Lizard.");
- } else if ((actionP1 == 5) && (actionP2 == 4)) {
- System.out.println(player1 + " wins! Scissors decapitates Lizard.");
- }
- if ((actionP1 == 3) && (actionP2 == 5)) {
- System.out.println(player1 + " wins! Spock smashes Scissors.");
- } else if ((actionP1 == 5) && (actionP2 == 3)) {
- System.out.println(player2 + " wins! Spock smashes Scissors.");
- }
- else {
- if (actionP1 == actionP2) {
- System.out.println("Draw!");
- }
- }
- }
- System.out.println("Thank you for playing.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement