-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.java
85 lines (75 loc) · 2.63 KB
/
Player.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import java.util.InputMismatchException;
import java.util.Scanner;
public class Player
{
static Scanner masuk = new Scanner(System.in);
public static int PilihPapan()
{
while(true)
{
try {
return masuk.nextInt();
} catch(InputMismatchException e){
System.out.print("Error, Masukkan 1 atau 2 atau 3 atau 4 : ");
masuk.next();
}
}
}
public static int PilihAngka()
{
while(true)
{
try {
return masuk.nextInt();
} catch(InputMismatchException e){
System.out.print("Error, Masukkan Angka Positif : ");
masuk.next();
}
}
}
public Player()
{
int papan, ukuran;
boolean cek = true;
boolean angka = true;
System.out.print("\033[H\033[2J");
do
{
System.out.println("===== Game SOS Player 1 vs Player 2 =====\n");
System.out.println("1. Papan 3 x 3");
System.out.println("2. Papan 5 x 5");
System.out.println("3. Papan 7 x 7");
System.out.println("4. Papan Custom");
System.out.print("\nPilih Ukuran Papan : ");
papan = PilihPapan();
if(papan == 1){
Papanx3 main = new Papanx3();
cek = false;
} else if(papan == 2){
Papanx5 main = new Papanx5();
cek = false;
} else if(papan == 3){
Papanx7 main = new Papanx7();
cek = false;
} else if(papan == 4){
System.out.println();
do
{
System.out.print("Masukkan Angka Positif : ");
ukuran = PilihAngka();
if(-1 < ukuran){
angka = false;
} else{
System.out.print("Error, ");
}
} while(angka);
PapanxN main = new PapanxN(ukuran);
cek = false;
} else{
System.out.print("\033[H\033[2J");
System.out.println("Error, Pilihan Papan Tidak Ada !!!\n");
}
} while(cek);
masuk.close();
}
}