Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class Lab4Problem1StewartSpencer {
- public static void main(String[] args) {
- int x;
- int y;
- Random randomGenerator = new Random();
- Scanner input= new Scanner(System.in);
- System.out.print("Human player: Enter 0 for rock, 1 for scissors, 2 for paper, 3 for lizard, 4 for spock:");
- x = input.nextInt();
- System.out.print("Computer player: Enter 0 for rock, 1 for scissors, 2 for paper, 3 for lizard, 4 for spock:");
- int randomInt = randomGenerator.nextInt(4);
- switch(x)
- {
- case '0':
- switch (randomInt)
- {
- case '1':
- System.out.print("Human Wins!");
- break;
- case '2':
- System.out.println("Computer Wins!");
- break;
- case '0':
- System.out.println("Draw!");
- break;
- case '3':
- System.out.println("Human Wins!");
- break;
- case '4':
- System.out.println("Computer Wins!");
- break;
- }
- }
- switch (x)
- {
- case 'R':
- switch(randomInt)
- {
- case 'S':
- System.out.println("Player 1 Wins!");
- break;
- case 'P':
- System.out.println("Player 2 Wins!");
- break;
- case 'R':
- System.out.println("Draw!");
- break;
- }
- }
- switch (x)
- {
- case 'S':
- switch (randomInt)
- {
- case 'P':
- System.out.println("Player 1 Wins!");
- break;
- case 'R':
- System.out.println("Player 2 Wins!");
- break;
- case ('S'):
- System.out.println("Draw!");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement