Advertisement
Guest User

Same shit again

a guest
Feb 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.40 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  *
  5.  *
  6.  */
  7. public class Main {
  8.  
  9.     /**
  10.      * @param args the command line arguments
  11.      */
  12.     public static void main(String[] args) {
  13.         String player1, player2, line;
  14.         int actionP1, actionP2;
  15.         Scanner kb = new Scanner(System.in);
  16.         //Make sure statements are accurate to diagram!
  17.         System.out.println("Player 1, please enter your name:");
  18.         player1 = kb.nextLine();
  19.  
  20.         System.out.println("Player 2, please enter your name:");
  21.         player2 = kb.nextLine();
  22.  
  23.         System.out.println(player1 + ", please enter your command:");
  24.         line = kb.nextLine();
  25.         actionP1 = Integer.parseInt(line);
  26.  
  27.         System.out.println(player2 + ", please enter your command:");
  28.         line = kb.nextLine();
  29.         if ((actionP1 > 5) || (actionP1 < 1)) {
  30.             System.out.println("I'm sorry, this is not a valid command.");
  31.         }else{
  32.             actionP2 = Integer.parseInt(line);
  33.             if ((actionP2 > 5) || (actionP2 < 1)) {
  34.                 System.out.println("I'm sorry, this is not a valid command.");
  35.             }else{
  36.                 if ((actionP1 == 1) && (actionP2 == 2)) {
  37.                     System.out.println(player1 + " wins! Paper covers Rock.");
  38.                 } else if ((actionP1 == 2) && (actionP2 == 1)) {
  39.                     System.out.println(player2 + " wins! Paper covers Rock.");
  40.                 }
  41.                 if ((actionP1 == 1) && (actionP2 == 3)) {
  42.                     System.out.println(player1 + " wins! Paper disproves Spock.");
  43.                 } else if ((actionP1 == 3) && (actionP2 == 1)) {
  44.                     System.out.println(player2 + " wins! Paper disproves Spock.");
  45.                 }
  46.                 if ((actionP1 == 1) && (actionP2 == 5)) {
  47.                     System.out.println(player2 + " wins! Scissors cuts Paper.");
  48.                 } else if ((actionP2 == 1) && (actionP1 == 5)) {
  49.                     System.out.println(player1 + " wins! Scissors cuts Paper.");
  50.                 } else if ((actionP1 == 1) && (actionP2 == 4)) {
  51.                     System.out.println(player2 + " wins! Lizard eats Paper.");
  52.                 }
  53.                 if ((actionP1 == 4) && (actionP2 == 1)) {
  54.                     System.out.println(player1 + " wins! Lizard eats Paper.");
  55.                 }
  56.  
  57.                 if ((actionP1 == 2) && (actionP2 == 3)) {
  58.                     System.out.println(player2 + " wins! Spock vaporizes Rock.");
  59.                 }
  60.                 if ((actionP2 == 2) && (actionP1 == 3)) {
  61.                     System.out.println(player1 + " wins! Spock vaporizes Rock.");
  62.                 } else if ((actionP1 == 2) && (actionP2 == 5)) {
  63.                     System.out.println(player1 + " wins! Rock crushes Scissors.");
  64.                 } else if ((actionP1 == 5) && (actionP2 == 2)) {
  65.                     System.out.println(player2 + " wins! Rock crushes Scissors.");
  66.                 }
  67.                 if ((actionP1 == 2) && (actionP2 == 4)) {
  68.                     System.out.println(player1 + " wins! Rock crushes Lizard.");
  69.                 } else if ((actionP1 == 4) && (actionP2 == 2)) {
  70.                     System.out.println(player2 + " wins! Rock crushes Lizard.");
  71.                 }
  72.                 if ((actionP1 == 4) && (actionP2 == 3)) {
  73.                     System.out.println(player1 + " wins! Lizard poisons Spock.");
  74.                 } else if ((actionP1 == 3) && (actionP2 == 4)) {
  75.                     System.out.println(player2 + " wins! Lizard poisons Spock.");
  76.                 }
  77.                 if ((actionP1 == 4) && (actionP2 == 5)) {
  78.                     System.out.println(player2 + " wins! Scissors decapitates Lizard.");
  79.                 } else if ((actionP1 == 5) && (actionP2 == 4)) {
  80.                     System.out.println(player1 + " wins! Scissors decapitates Lizard.");
  81.                 }
  82.                 if ((actionP1 == 3) && (actionP2 == 5)) {
  83.                     System.out.println(player1 + " wins! Spock smashes Scissors.");
  84.                 } else if ((actionP1 == 5) && (actionP2 == 3)) {
  85.                     System.out.println(player2 + " wins! Spock smashes Scissors.");
  86.                 }
  87.  
  88.              else {
  89.                 if (actionP1 == actionP2) {
  90.                     System.out.println("Draw!");
  91.                 }
  92.             }
  93.         }
  94.         System.out.println("Thank you for playing.");
  95.     }
  96.  
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement