-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4_corners.java
46 lines (32 loc) · 1.18 KB
/
4_corners.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
import java.util.*;
public class MyClass {
public static void main(String args[]) {
System.out.println("Welcome to 4 Corners")
Boolean running = true;
while (running) {
Boolean alive = true;
while (alive) {
List<String> walls = new ArrayList<String>(4);
walls.add("1");
walls.add("2");
walls.add("3");
walls.add("4");
Random wall = new Random();
String wall = wall.nextInt(5);
String guess;
do {
System.out.println("Choose a wall")
Scanner sc = new Scanner(System.in);
guess = sc.nextLine();
} while (walls.contains(guess));
String wall = String.valueOf(wall);
if (guess.equals(wall)) {
System.out.println("Oh No! the computer picked your corner");
alive = false;
} else {
System.out.println("You are safe. the computer picked corner " + wall);
}
}
}
}
}