-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathView.java
More file actions
55 lines (49 loc) · 1.68 KB
/
View.java
File metadata and controls
55 lines (49 loc) · 1.68 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
package racingcar;
import camp.nextstep.edu.missionutils.Console;
import racingcar.Model.Car;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class View {
public String inputCarNames() {
String carNames = "";
try {
System.out.println("자동차의 이름들을 입력하세요");
carNames = Console.readLine();
} catch (Exception e) {
System.out.println("Exception [Err_location] : " + e.getStackTrace()[0]);
throw new RuntimeException(e);
}
return carNames;
}
public int inputFrequency() {
try {
System.out.println("총 시도할 횟수를 입력하세요");
return Integer.parseInt(Console.readLine());
} catch (Exception e) {
System.out.println("Exception [Err_location] : " + e.getStackTrace()[0]);
throw new RuntimeException(e);
}
}
public void printCarProgress(List<Car> cars, int length) {
for (int index = 0; index < length; index++) {
System.out.print(cars.get(index).getName() + " : ");
int progress = cars.get(index).getProgress();
for (int i = 0; i < progress; i++) {
System.out.print("-");
}
System.out.println();
}
System.out.println();
}
public void printWinner(List<String> winner) {
System.out.print("최종 우승자 : ");
for (int i = 0; i < winner.size(); i++) {
System.out.print(winner.get(i));
if (i + 1 < winner.size()) {
System.out.print(",");
}
}
}
}