-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFireAlarmApp.java
More file actions
191 lines (165 loc) · 9.24 KB
/
FireAlarmApp.java
File metadata and controls
191 lines (165 loc) · 9.24 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import java.io.*;
import java.util.*;
public class FireAlarmApp {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
OnFireMountain onFireMountain = new OnFireMountain();
while(true){
if (!onFireMountain.getOnFireMountain().isEmpty()) {
System.out.print("\u001B[31m현재\u001B[0m ");
// 중복 제거
Set<String> firingMountains = new HashSet<>(onFireMountain.getOnFireMountain());
for (String s : firingMountains) {
System.out.print("[" + s + "]" + " ");
}
System.out.println("\u001B[31m인근에서 산불 발생 위험!! 인근 주민은 대피 준비하시길 바랍니다.\u001B[0m");
}
System.out.println("--------------------------------------------------------------");
System.out.println("[대구 산불 예방 및 대처 애플리케이션]\n");
System.out.println("1. 대구 산불 발생 신고하기");
System.out.println("2. 대구 산불 위험 현황 보기");
System.out.println("3. 산불 진행 예측하기");
System.out.println("4. 우리 동네 대피소 확인하기");
System.out.println("5. 산불 대처 방법 알아보기");
System.out.println("6. 산불 위험 지수 지도 보기");
System.out.println("0. 시스템 종료");
System.out.println("--------------------------------------------------------------");
System.out.print("메뉴를 선택해 주세요: ");
String answer = scanner.nextLine().trim();
System.out.println();
switch (answer) {
case "1":
while(true){
System.out.println("1. 산불 발생 신고하기");
System.out.println("2. 메인메뉴로 돌아가기");
System.out.print("-> ");
String answer2 = scanner.nextLine().trim();
System.out.println();
if(answer2.equals("1")) {
while(true){
System.out.println("1. 산 이름을 아는 경우");
System.out.println("2. 산 이름을 모르는 경우");
System.out.println("3. 뒤로 가기");
System.out.print("-> ");
String answer3 = scanner.nextLine().trim();
System.out.println();
if(answer3.equals("1")) {
System.out.print("산불이 난 산의 이름을 입력하세요: ");
String mountain= scanner.nextLine().trim();
onFireMountain.setOnFireMountain(mountain);
System.out.println("신고가 접수되었습니다. 감사합니다.\n");
break;
}else if(answer3.equals("2")) {
NotifyFire notifyFire = new NotifyFire();
if(notifyFire.setInfo(scanner))
notifyFire.getInfo();
if (notifyFire.getMountain() != null) {
onFireMountain.setOnFireMountain(notifyFire.getMountain());
}
}else if(answer3.equals("3")) {
break;
}else
System.out.println("올바른 번호를 입력해주세요.");
}
}else if(answer2.equals("2")) {
break;
}else{
System.out.println("올바른 번호를 입력해주세요.");
}
}
break;
case "2":
while(true){
System.out.println("1. 현재 접수된 신고 현황");
System.out.println("2. 메인으로 돌아가기 ");
System.out.print("-> ");
String answer2 = scanner.nextLine().trim();
if(answer2.equals("1")) {
if(onFireMountain.getOnFireMountain().isEmpty()){
System.out.println("현재 접수된 신고가 없습니다.");
}else{
FireStatus fireStatus = new FireStatus();
fireStatus.runFireStatus(onFireMountain.getOnFireMountain(), scanner);
}
}else if(answer2.equals("2"))
break;
else
System.out.println("메뉴를 다시 입력해주세요");
}
break;
case "3":
while(true){
System.out.println("1. 현재 풍향에 따른 위험지역 예측하기");
System.out.println("2. 메인으로 돌아가기 ");
System.out.print("-> ");
String answer2 = scanner.nextLine().trim();
if(answer2.equals("1")) {
if(onFireMountain.getOnFireMountain().isEmpty()) {
System.out.println("현재 접수된 신고가 없습니다.");
}else{
System.out.print("지역명을 입력하세요 (예: 북구, 동구 등): ");
String regionInput = scanner.nextLine().trim();
String tableName = switch (regionInput) {
case "북구" -> "buk_mountains";
case "동구" -> "dong_mountains";
case "달성군" -> "dalseong_mountains";
case "달서구" -> "dalseo_mountains";
case "군위군" -> "gunwi_mountains";
case "서구" -> "seo_mountains";
case "남구" -> "nam_mountains";
case "수성구" -> "suseong_mountains";
case "중구" -> "jung_mountains";
default -> {
System.out.println("지원하지 않는 지역입니다.");
yield null;
}
};
if (tableName != null) {
Predict predict = new Predict();
List<String> mountainsOnFire = onFireMountain.getOnFireMountain();
predict.checkMountains(mountainsOnFire, regionInput, tableName);
}
}
}else if(answer2.equals("2"))
break;
else
System.out.println("메뉴를 다시 입력해주세요");
}
break;
case "4":
String region;
while(true){
System.out.println("지역을 입력하세요.(종료: q 또는 Q 입력) ");
System.out.println("ex) 대구광역시, 북구, 비산동");
System.out.print("-> ");
region = scanner.nextLine().toUpperCase().trim();
if(!region.equals("Q")){
ShelterLocation shelterLocation = new ShelterLocation();
shelterLocation.printShelterLocation(region);
}else{
break;
}
}
break;
case "5":
List<Quiz> quizzes = QuizLoader.loadFromFile("ox_quiz.txt");
if (quizzes != null && !quizzes.isEmpty()) {
QuizManager manager = new QuizManager(quizzes);
manager.run();
} else {
System.out.println("퀴즈가 없습니다. 파일을 확인해주세요.");
}
break;
case "6":
DangerPointMap dpm = new DangerPointMap();
dpm.InputAndSwing();
break;
case "0":
System.out.println("시스템을 종료합니다.");
return;
default:
System.out.println("유효한 번호를 입력해 주세요(0~6)");
}
}
}
}