Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3.  
  4. class Main
  5. {
  6.     public static void main(String[] args)
  7.     {
  8.         Scanner scan = new Scanner(System.in);
  9.         String choice;
  10.         Random random = new Random();
  11.         int rand = random.nextInt(2);
  12.         String[] CompChoices = {"Rock", "Paper", "Scissors"};
  13.         String BotChoice = CompChoices[rand];
  14.  
  15.         System.out.println("Rock, Paper, or Scissors");
  16.         choice = scan.nextLine();
  17.         WhoWon(choice, BotChoice);
  18.     }
  19.  
  20.     public static void WhoWon(String brad, String chad)
  21.     {
  22.         String player = brad;
  23.         String comp = chad;
  24.  
  25.         if ((chad.equalsIgnoreCase("Rock")) && (brad.equalsIgnoreCase("Rock")))           System.out.println("You Tied");
  26.         if ((player.equalsIgnoreCase("Rock")) && (comp.equalsIgnoreCase("Paper")))        System.out.println("You Lose");
  27.         if ((player.equalsIgnoreCase("Rock")) && (comp.equalsIgnoreCase("Scissors")))     System.out.println("You Win");
  28.         if ((player.equalsIgnoreCase("Paper")) && (comp.equalsIgnoreCase("Rock")))        System.out.print("You Win");
  29.         if ((player.equalsIgnoreCase("Paper")) && (comp.equalsIgnoreCase("Paper")))       System.out.print("You Tied");
  30.         if ((player.equalsIgnoreCase("Paper")) && (comp.equalsIgnoreCase("Scissors")))    System.out.print("You Lose");
  31.         if ((player.equalsIgnoreCase("Scissors")) && (comp.equalsIgnoreCase("Rock")))     System.out.print("You Lose");
  32.         if ((player.equalsIgnoreCase("Scissors")) && (comp.equalsIgnoreCase("Paper")))    System.out.print("You Win");
  33.         if ((player.equalsIgnoreCase("Scissors")) && (comp.equalsIgnoreCase("Scissors"))) System.out.print("You Tied");
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement