-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathApplication.java
More file actions
51 lines (40 loc) · 1.64 KB
/
Application.java
File metadata and controls
51 lines (40 loc) · 1.64 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
public class Application {
public static void main(String[] args) {
boolean continueFlag = true;
boolean makeFlag = true;
int[] randomNumbers = Utility.makeRandomNumbers();
int[] userNumbers;
while (continueFlag) {
if (makeFlag) {
makeFlag = false;
randomNumbers = Utility.makeRandomNumbers();
}
System.out.print("숫자를 입력해 주세요 : ");
String userString = Utility.getUserString();
try {
Utility.checkStringLength(userString);
Utility.checkStringDistinct(userString);
Utility.checkStringDigit(userString);
} catch (IllegalArgumentException e) {
System.out.print("올바르지 않은 입력입니다. ");
break;
}
userNumbers = Utility.stringToIntArray(userString);
int strike = Utility.strikeCount(randomNumbers, userNumbers);
int ball = Utility.ballCount(randomNumbers, userNumbers);
System.out.println(Utility.getStrikeBall(strike, ball));
Utility.printEndMessage(strike);
if (strike == 3) {
userString = Utility.getUserString();
makeFlag = true;
}
try {
continueFlag = Utility.checkKeepGoing(userString, strike);
} catch (IllegalArgumentException e) {
System.out.print("올바르지 않은 입력입니다. ");
break;
}
}
System.out.println("애플리케이션을 종료합니다.");
}
}