-
Notifications
You must be signed in to change notification settings - Fork 0
/
PedraPapelTesoura.java
67 lines (49 loc) · 2.02 KB
/
PedraPapelTesoura.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.util.Scanner;
public class PedraPapelTesoura {
public static void main(String[] args)
Scanner scanner = new Scanner(System.in);
while (true) {
String[] ppt = {"p", "p", "t"};
String computerMove = ppt [new random(). nextInt (ppt.length)];
String playerMove;
}
while (true) {
System.out.println("Please enter your move (p, p, ou t)");
playerMove = scanner.nextLine();
if (playerMove.equals.("p") | | playerMove.equals.("p") | | playerMove.equals.("t")) {
break;
}
System.out.println(playerMove + " is not a valid move.");
System.out.println("computer played: " + computerMove);
if (playerMove.equals(computerMove)) {
System.out.println("The game was a tie!");
}
else if (playerMove.equals("p")) {
if (computerMove.equals("p")){
System.out.println("You lose!");
} else if (computerMove.equals ("t")) {
System.out.printlin("You win!");
else if (playerMove.equals("p")) {
if (computerMove.equals("p")){
System.out.println("You win!");
} else if (computerMove.equals ("t")) {
System.out.printlin("You lose!");
else if (playerMove.equals("t")) {
if (computerMove.equals("p")){
System.out.println("You win!");
} else if (computerMove.equals ("p")) {
System.out.printlin("You lose!");
}
}
System.out.printlin("Play again? (y/n)");
String playAgain = scanner.nextLine();
if (!playAgain.equals("y")) {
break;
}
scanner.close();
}
}
}
}
}
}