Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- class Main
- {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- String choice;
- Random random = new Random();
- int rand = random.nextInt(2);
- String[] CompChoices = {"Rock", "Paper", "Scissors"};
- String BotChoice = CompChoices[rand];
- System.out.println("Rock, Paper, or Scissors");
- choice = scan.nextLine();
- WhoWon(choice, BotChoice);
- }
- public static void WhoWon(String brad, String chad)
- {
- String player = brad;
- String comp = chad;
- if ((chad.equalsIgnoreCase("Rock")) && (brad.equalsIgnoreCase("Rock"))) System.out.println("You Tied");
- if ((player.equalsIgnoreCase("Rock")) && (comp.equalsIgnoreCase("Paper"))) System.out.println("You Lose");
- if ((player.equalsIgnoreCase("Rock")) && (comp.equalsIgnoreCase("Scissors"))) System.out.println("You Win");
- if ((player.equalsIgnoreCase("Paper")) && (comp.equalsIgnoreCase("Rock"))) System.out.print("You Win");
- if ((player.equalsIgnoreCase("Paper")) && (comp.equalsIgnoreCase("Paper"))) System.out.print("You Tied");
- if ((player.equalsIgnoreCase("Paper")) && (comp.equalsIgnoreCase("Scissors"))) System.out.print("You Lose");
- if ((player.equalsIgnoreCase("Scissors")) && (comp.equalsIgnoreCase("Rock"))) System.out.print("You Lose");
- if ((player.equalsIgnoreCase("Scissors")) && (comp.equalsIgnoreCase("Paper"))) System.out.print("You Win");
- if ((player.equalsIgnoreCase("Scissors")) && (comp.equalsIgnoreCase("Scissors"))) System.out.print("You Tied");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement