Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. /*
  2. * Alex Bowman\
  3. * CSE 111
  4. * HW#3 with extra credit
  5. * Professor Silvestri
  6. * 9/27
  7. *
  8. *
  9. * Scissors cuts Paper, Paper covers Rock, Rock crushes Lizard, Lizard poisons
  10. * Spock, Spock smashes Scissors, Scissors decapitates Lizard, Lizard eats Paper,
  11. * Paper disproves Spock, Spock vaporizes Rock
  12. */
  13. import java.util.Random;
  14. import java.util.Scanner;
  15.  
  16. public class RPS {
  17. public static void main(String[] args) {
  18.  
  19. {
  20. int R = 0; // R = Rock
  21. int P = 1; // P = Paper
  22. int S = 2; // S = Scissors
  23. int L = 3; // L= Lizard
  24. int Sp = 4; // Sp= Spock
  25.  
  26. int u; // User
  27. int c; // Computer
  28. Scanner Scan = new Scanner(System.in);
  29. Random Rnum = new Random();
  30.  
  31. System.out.println("0. Rock");
  32. System.out.println("1. Paper");
  33. System.out.println("2. Scissors");
  34. System.out.println("3. Lizard");
  35. System.out.println("4. Spock");
  36. System.out.println("please enter the number that cooresponds to your desired move: ");
  37. u = Scan.nextInt();
  38.  
  39. c = Rnum.nextInt(5);
  40.  
  41. System.out.println("you picked " + u +", " + " the computer picked " + c + ".");
  42. if ((u < 0) || (u > 4)) {
  43. {
  44. System.out.println("Please enter in a number that cooresponds to a move");
  45. }
  46. } else if (u == c) {
  47. System.out.println("\n******Draw******");
  48. } else if ((u == R && c == S) || (u == R && c == L) || (u == S && c == L) || (u == S && c == P)
  49. || (u == P && c == Sp) || (u == P && c == R) || (u == L && c == Sp) || (u == L && c == P)
  50. || (u == Sp && c == S) || (u == Sp && c == R)) {
  51. System.out.println("\n******You won!******");
  52. }
  53.  
  54. else {
  55. System.out.println("\n******You have been defeated!*******");
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement