forked from Bunsan-BokhakClub/InsuranceService
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
410 lines (334 loc) · 16.2 KB
/
Main.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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
import compensation.CompensationClaim;
import compensation.CompensationClaimListImpl;
import compensation.Servey;
import contract.Contract;
import contract.ContractListImpl;
import insurance.*;
import partner.Partner;
import partner.PartnerListImpl;
import payment.Payment;
import payment.PaymentListImpl;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private static int insuranceIndex = 1;
private static ContractListImpl contractList;
private static PartnerListImpl partnerList;
private static CompensationClaimListImpl compensationClaimList;
private static InsuranceListImpl insuranceList;
private static PaymentListImpl paymentList;
public static void main(String[] args) throws IOException {
ArrayList<Insurance> insList = new ArrayList<>();
insuranceList = new InsuranceListImpl(insList);
ArrayList<Contract> conList = new ArrayList<>();
contractList = new ContractListImpl(conList);
ArrayList<Partner> partList = new ArrayList<>();
partnerList = new PartnerListImpl(partList);
ArrayList<CompensationClaim> compList = new ArrayList<>();
compensationClaimList = new CompensationClaimListImpl(compList);
ArrayList<Payment> payList = new ArrayList<>();
paymentList = new PaymentListImpl(payList);
String userChoice = "";
while (!userChoice.equals("x")) {
showMenu();
userChoice = br.readLine().trim();
switch (userChoice) {
case "1":
claimInsurance();
break;
case "2":
queryInsurance();
break;
case "3":
checkMyInsurance();
break;
case "4":
fileComplaint();
break;
case "5":
payInsurance();
break;
case "6":
queryPartnerCompanies();
break;
case "7":
assessDamage();
break;
case "8":
registerInsurance();
break;
case "9":
modifyInsurance();
break;
case "10":
queryCustomerInfo();
break;
case "11":
queryEmployeeInfo();
break;
case "12":
queryContractInfo();
break;
case "13":
queryInsuranceApplication();
break;
case "x":
break;
default:
if (!userChoice.equals("x")) {
System.out.println("Invalid choice. Please try again.");
}
}
}
}
public static void showMenu() {
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("7. 손해 사정 한다");
System.out.println("8. 보험 등록한다");
System.out.println("9. 보험 수정한다");
System.out.println("10. 고객 정보 조회");
System.out.println("11. 직원 정보 조회");
System.out.println("12. 계약 정보 조회");
System.out.println("13. 보험 가입 신청 내역 조회");
}
public static void claimInsurance() throws IOException {
System.out.println("보상금 청구를 처리합니다.\n");
System.out.println("가입자의 성함과 전화번호를 입력해주세요");
System.out.print("성함 : ");
String name = br.readLine().trim();
System.out.print("전화번호 : ");
String pN = br.readLine().trim();
Contract contract = contractList.getContractByNameAndPN(name, pN);
if (contract != null) {
System.out.println("계약 정보:");
System.out.println("보험 이름: " + contract.getInsuranceName());
System.out.println("고객 이름: " + contract.getCustomerName());
System.out.println("전화번호: " + contract.getPhoneNumber());
System.out.println("\n금액을 청구하시겠습니까?");
System.out.print("Y / N : ");
String yN = br.readLine().trim();
if (yN.equalsIgnoreCase("Y")) {
processClaim(contract);
} else {
System.out.println("금액 청구가 취소되었습니다.");
}
} else {
System.out.println("해당 고객 정보를 찾을 수 없습니다.");
}
}
public static void processClaim(Contract contract) throws IOException {
System.out.println("청구 정보를 입력해주세요.");
System.out.print("접수자 이름: ");
String claimantName = br.readLine().trim();
System.out.print("접수자 전화번호: ");
String claimantPhone = br.readLine().trim();
System.out.print("업체명: ");
String partnerName = br.readLine().trim();
System.out.print("청구 금액: ");
int claimValue = Integer.parseInt(br.readLine().trim());
System.out.print("청구 서류: ");
String claimDocument = br.readLine().trim();
System.out.print("은행: ");
String bank = br.readLine().trim();
System.out.print("계좌번호: ");
String accountNumber = br.readLine().trim();
System.out.print("예금주명: ");
String accountHolder = br.readLine().trim();
Partner partner = partnerList.getPartnerByName(partnerName);
Servey servey = new Servey(claimantName, bank, accountNumber,accountHolder, claimValue, partner);
CompensationClaim compensationClaim = new CompensationClaim(contract.getCustomerID(), contract.getCustomerName(), claimDocument,
contract.getInsuranceID(), contract.getInsuranceName(), servey);
if(partner != null) {
compensationClaimList.add(compensationClaim);
System.out.println("\n청구가 완료되었습니다.");
} else {
System.out.println("\n 청구에 실패하였습니다. 다시 시도해주세요.");
}
}
public static void queryInsurance() {
System.out.println("보험 조회를 처리합니다.");
}
public static void checkMyInsurance() {
System.out.println("내 보험 확인을 처리합니다.");
}
public static void fileComplaint() {
System.out.println("민원 접수를 처리합니다.");
}
public static void payInsurance() throws IOException {
System.out.println("보험금 납부를 처리합니다.\n");
System.out.println("고객 정보를 입력해주세요");
System.out.print("성명 : ");
String cusName = br.readLine().trim();
// 2. 보험 정보 리스트와 버튼(납부) 출력
System.out.println("보험 목록:");
ArrayList<Contract> contracts = contractList.getContractListByCusName(cusName);
for (Contract contract : contracts) {
System.out.println("보험명: " + contract.getInsuranceName() + ", 보험료: " + contract.getPaymentAmount());
}
// 3. 납부를 원하는 보험 조회
System.out.print("\n납부를 원하는 보험의 이름을 입력하세요: ");
String insuranceName = br.readLine().trim();
Contract contract = contractList.getContractByInsName(insuranceName);
if (contract == null) {
System.out.println("해당 이름의 보험을 찾을 수 없습니다.");
return;
} else {
System.out.println("보험명: " + contract.getInsuranceName() + ", 보험료: " + contract.getPaymentAmount());
}
// 4. 납부 정보 입력창과 버튼(제출) 출력
System.out.println("\n납부 정보를 입력하세요.");
System.out.print("은행 이름: ");
String bankName = br.readLine().trim();
System.out.print("계좌번호: ");
String accountNumber = br.readLine().trim();
System.out.print("예금주명: ");
String accountHolder = br.readLine().trim();
Payment payment = new Payment(contract.getCustomerID(), contract.getInsuranceID(), contract.getPaymentAmount(), bankName, accountNumber, accountHolder);
paymentList.add(payment);
// 6. 납부 완료 메시지 출력
System.out.println("\n납부가 완료되었습니다.");
}
public static void queryPartnerCompanies() {
System.out.println("협력 업체 조회를 처리합니다.");
}
public static void assessDamage() {
System.out.println("손해 사정을 처리합니다.");
}
public static void registerInsurance() throws IOException {
System.out.println("보험 등록을 처리합니다.\n");
System.out.println("보험종류");
System.out.println("1. 일반보험 || 2. 건강보험 || 3. 자동차보험 || 4. 여행자보험");
System.out.println("등록하실 보험 종류의 숫자를 입력해주세요");
int insuranceType = Integer.parseInt(br.readLine().trim());
System.out.print("보험 이름: ");
String insuranceName = br.readLine().trim();
System.out.print("보험료: ");
int insurancePremium = Integer.parseInt(br.readLine().trim());
System.out.print("보상금: ");
int compensationAmount = Integer.parseInt(br.readLine().trim());
System.out.print("갱신 상태 (자동갱신/비갱신): ");
String renewalStatus = br.readLine().trim();
System.out.print("갱신 주기: ");
int renewalCycle = Integer.parseInt(br.readLine().trim());
System.out.print("보험 기간: ");
int insurancePeriod = Integer.parseInt(br.readLine().trim());
Insurance insurance = new Insurance(insuranceIndex++, insuranceName, compensationAmount, renewalStatus,
insurancePremium, renewalCycle, insurancePeriod);
switch (insuranceType) {
case 1:
insuranceList.add(insurance);
break;
case 2:
registerHealthInsurance(insurance);
break;
case 3:
registerCarInsurance(insurance);
break;
case 4:
registerTravelInsurance(insurance);
break;
}
System.out.println("\n신규 보험 등록이 완료되었습니다.");
}
private static void registerHealthInsurance(Insurance insurance) throws IOException {
System.out.print("보장 질환 목록 (쉼표로 구분하여 입력하세요): ");
String[] diseases = br.readLine().trim().split(",");
ArrayList<String> diseaseList = new ArrayList<>(Arrays.asList(diseases));
Insurance healthInsurance = new HealthInsurance(insurance, diseaseList);
insuranceList.add(healthInsurance);
}
private static void registerCarInsurance(Insurance insurance) throws IOException {
System.out.print("자동차 모델: ");
String carModel = br.readLine().trim();
System.out.print("주행 거리: ");
int carDistance = Integer.parseInt(br.readLine().trim());
System.out.print("자동차 생산 연도: ");
String carYear = br.readLine().trim();
Insurance carInsurance = new CarInsurance(insurance, carDistance, carModel, carYear);
insuranceList.add(carInsurance);
}
private static void registerTravelInsurance(Insurance insurance) throws IOException {
System.out.print("여행 국가명: ");
String countryName = br.readLine().trim();
System.out.print("여행 날짜: ");
int travelDate = Integer.parseInt(br.readLine().trim());
Insurance travelInsurance = new TravelInsurance(insurance, countryName, travelDate);
insuranceList.add(travelInsurance);
}
public static void modifyInsurance() throws IOException {
System.out.println("보험 수정을 처리합니다.\n");
// 2. 보험 이름 입력창 출력
System.out.print("보험 이름을 입력하세요: ");
String insuranceName = br.readLine().trim();
// 3. 해당 정보를 입력 후 조회
Insurance insurance = insuranceList.getInsuranceByName(insuranceName);
if (insurance == null) {
System.out.println("해당 이름의 보험을 찾을 수 없습니다.");
return;
}
// 4. 해당 보험의 정보 수정창 출력
System.out.println("현재 보험 정보:");
System.out.println("보험 이름: " + insurance.getInsuranceName());
System.out.println("보험료: " + insurance.getPaymentAmount());
System.out.println("보상금: " + insurance.getCompensationAmount());
System.out.println("갱신 상태: " + insurance.getCycleType());
System.out.println("갱신 주기: " + insurance.getPaymentCycle());
System.out.println("보험 기간: " + insurance.getInsurancePeriod());
System.out.println("\n새로운 정보를 입력하세요 (변경하지 않으려면 Enter 키를 누르세요):");
// 5. 정보 수정 입력
System.out.print("보험 이름 (" + insurance.getInsuranceName() + "): ");
String newInsuranceName = br.readLine().trim();
if (!newInsuranceName.isEmpty()) {
insurance.setInsuranceName(newInsuranceName);
}
System.out.print("보험료 (" + insurance.getPaymentAmount() + "): ");
String newInsurancePremiumStr = br.readLine().trim();
if (!newInsurancePremiumStr.isEmpty()) {
int newInsurancePremium = Integer.parseInt(newInsurancePremiumStr);
insurance.setPaymentAmount(newInsurancePremium);
}
System.out.print("보상금 (" + insurance.getCompensationAmount() + "): ");
String newCompensationAmountStr = br.readLine().trim();
if (!newCompensationAmountStr.isEmpty()) {
int newCompensationAmount = Integer.parseInt(newCompensationAmountStr);
insurance.setCompensationAmount(newCompensationAmount);
}
System.out.print("갱신 상태 (" + insurance.getCycleType() + "): ");
String newRenewalStatus = br.readLine().trim();
if (!newRenewalStatus.isEmpty()) {
insurance.setCycleType(newRenewalStatus);
}
System.out.print("갱신 주기 (" + insurance.getPaymentCycle() + "): ");
String newRenewalCycle = br.readLine().trim();
if (!newRenewalCycle.isEmpty()) {
insurance.setPaymentCycle(newRenewalCycle);
}
System.out.print("보험 기간 (" + insurance.getInsurancePeriod() + "): ");
String newInsurancePeriod = br.readLine().trim();
if (!newInsurancePeriod.isEmpty()) {
insurance.setInsurancePeriod(newInsurancePeriod);
}
System.out.println("\n수정이 완료되었습니다.");
}
public static void queryCustomerInfo() {
System.out.println("고객 정보 조회를 처리합니다.");
}
public static void queryEmployeeInfo() {
System.out.println("직원 정보 조회를 처리합니다.");
}
public static void queryContractInfo() {
System.out.println("계약 정보 조회를 처리합니다.");
}
public static void queryInsuranceApplication() {
System.out.println("보험 가입 신청 내역 조회를 처리합니다.");
}
}