-
Notifications
You must be signed in to change notification settings - Fork 741
/
Copy pathResultView.java
68 lines (56 loc) · 1.96 KB
/
ResultView.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
package nextstep.ladder.view;
import nextstep.ladder.domain.*;
public class ResultView {
private static final String BLANK = " ";
private static final String LINE = "-----";
private static final String COLUMN = "|";
private ResultView() { // 인스턴스화 방지
}
public static void printParticipantsName(Participants participants) {
participants.getParticipants().forEach(participant -> System.out.print(String.format("%-8s", participant.getName())));
enter();
}
public static void printLadderWord() {
System.out.println("사다리 결과");
enter();
}
public static void printLadder(Ladder ladder) {
ladder.getLines().forEach(line -> {
printPoints(line);
System.out.println();
});
}
private static void printPoints(Line line) {
line.getPoints().forEach(point -> {
System.out.print(point.getCurrent() ? LINE : BLANK);
System.out.print(COLUMN);
});
}
public static void enter() {
System.out.println();
}
public static void printResultWord() {
System.out.println("실행결과");
}
public static void printResultInfo(ResultInfo resultInfo) {
resultInfo.getResults().forEach(result -> System.out.print(String.format("%-8s", result)));
enter();
enter();
}
public static void printResultAll(Participants participants, ResultInfo resultInfo) {
enter();
printResultWord();
for (int i = 0; i < participants.count(); i++) {
Participant participant = participants.getParticipants().get(i);
System.out.println(participant.getName()
+ " : " + resultInfo.getResults().get(participant.getPosition()));
}
enter();
}
public static void printResultOfParticipant(String result) {
enter();
printResultWord();
System.out.println(result);
enter();
}
}