(String[] args)
| 6 | public rps { |
| 7 | |
| 8 | public static void main(String[] args) { |
| 9 | // TODO Auto-generated method stub |
| 10 | |
| 11 | System.out.println(" RPS "); |
| 12 | |
| 13 | int comScore = 0; |
| 14 | int userScore = 0; |
| 15 | |
| 16 | String [] RPS = {"Rock", "Paper", "Sciossors"}; |
| 17 | |
| 18 | Scanner scan = new Scanner(System.in); |
| 19 | |
| 20 | String userInput = scan.nextLine(); |
| 21 | |
| 22 | Random random = new Random(); |
| 23 | |
| 24 | int rand = random.nextInt(3); |
| 25 | |
| 26 | System.out.println(RPS[rand]); |
| 27 | |
| 28 | if(userInput.equals("Paper") && RPS [rand].equals("Scissors")) { |
| 29 | comScore = comScore + 1; |
| 30 | } |
| 31 | |
| 32 | else if (userInput == "Rock" && RPS [rand].equals("Paper")) { |
| 33 | userScore = userScore + 1; |
| 34 | } |
| 35 | |
| 36 | else if (userInput.equals ("Paper") && RPS [rand].equals("Rock")) { |
| 37 | comScore = comScore + 1; |
| 38 | } |
| 39 | |
| 40 | else if (userInput.equals ("Scissors") && RPS [rand].equals ("Rock")) { |
| 41 | userScore = userScore + 1; |
| 42 | } |
| 43 | |
| 44 | else if(userInput.equals ("Rock") && RPS [rand].equals ("Scissors")) { |
| 45 | comScore = comScore + 1; |
| 46 | } |
| 47 | |
| 48 | else if (userInput.equals("Scissors") && RPS [rand].equals ("Paper")) { |
| 49 | userScore = userScore + 1; |
| 50 | } |
| 51 | |
| 52 | else { |
| 53 | System.out.println(" It's a tie ! "); |
| 54 | } |
| 55 | |
| 56 | if (userScore > comScore) |
| 57 | System.out.println(" user win "); |
| 58 | |
| 59 | else |
| 60 | System.out.println(" com win"); |
| 61 | |
| 62 | |
| 63 | } |
| 64 | |
| 65 | } |
nothing calls this directly
no outgoing calls
no test coverage detected