-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartScreen.java
More file actions
78 lines (66 loc) · 4.36 KB
/
StartScreen.java
File metadata and controls
78 lines (66 loc) · 4.36 KB
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
package MainRepository;
import java.util.Scanner;
public class StartScreen extends Screen {
private static final String[] OPTIONS = {"Start Game", "Exit"};
private static void printCover() {
System.out.println("\n");
System.out.println(" ┏■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■┓ ");
System.out.println(" ■ ■");
System.out.println(" ■ ■■■■■■■■■■■■ ■■■■■■■■■■■■ ■■ ■■ ■■■■■■■■■■■■ ■■■■■■■■■■ ■");
System.out.println(" ■ ■■ ■■ ■■ ■■ ■■ ■■ ■■ ■■ ■■ ■");
System.out.println(" ■ ■■■■■■■■■■■■ ■■ ■■ ■■■■■■■■■ ■■■■■■■■■■■■ ■■■■■■■■■■ ■");
System.out.println(" ■ ■■ ■■ ■■ ■■ ■■ ■■ ■■ ■■ ■");
System.out.println(" ■ ■■ ■■■■■■■■■■■■ ■■ ■■ ■■■■■■■■■■■■ ■■ ■■ ■");
System.out.println(" ■ ■");
System.out.println(" ┗■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■┛\n");
}
public static void printMenu() {
for (int i = 0; i < OPTIONS.length; i++) {
if (i == selectedIndex) {
System.out.print(" -> ");
} else {
System.out.print(" ");
}
System.out.println(OPTIONS[i]);
}
System.out.println("\n W: Move Up, S: Move Down, E: Select");
System.out.print(" Select option >> ");
}
private static void moveSelectionUp() {
selectedIndex = (selectedIndex - 1 + OPTIONS.length) % OPTIONS.length;
}
private static void moveSelectionDown() {
selectedIndex = (selectedIndex + 1) % OPTIONS.length;
}
public static void printScreen(){
Scanner scanner = new Scanner(System.in);
while (true) {
clearConsole();
printCover(); // 시작 화면 표지 출력
printMenu(); // 메뉴 출력
if (scanner.hasNext()) {
char input = scanner.next().charAt(0);
if (input == 'W' || input == 'w') {
moveSelectionUp();
clearConsole();
}
else if (input == 'S' || input == 's') {
moveSelectionDown();
clearConsole();
}
else if (input == 'E' ||input == 'e') {
if (selectedIndex == 0) {
System.out.print(" Enter the number of players >> ");
Poker.numPlayers = scanner.nextInt();
// Start Game을 선택한 경우, 다음 화면으로 넘어가는 작업 추가
break;
}
else if (selectedIndex == 1) {
// Exit를 선택한 경우, 프로그램 종료
System.exit(0);
}
}
}
}
}
}