-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathOutputView.java
76 lines (59 loc) · 2.06 KB
/
OutputView.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
package view;
import domain.Ladder;
import domain.Line;
import domain.Player;
import domain.Players;
import java.util.List;
import static java.lang.Boolean.TRUE;
public class OutputView {
public static void printPlayers(List<String> names) {
System.out.println("\n사다리 결과\n");
names.forEach(System.out::print);
System.out.println();
}
private static String changeValueToView(Boolean point) {
if (point == TRUE)
return "-----";
return " ";
}
private static void drawLine(Line line) {
for (Boolean point : line.getLine()) {
System.out.print("|");
System.out.print(changeValueToView(point));
}
System.out.println("|");
}
public static void drawLadder(Ladder Ladder) {
for (Line lines : Ladder.getLadder()) {
drawLine(lines);
}
}
public static void printKindOfResults(List<String> kindOfResults) {
for (String kind : kindOfResults) {
System.out.print(kind);
}
System.out.println();
}
public static void printAllResult(Players players, List<String> kindOfResults) {
for (Player player : players.getPlayers()) {
System.out.println(player.getName() + " : " + kindOfResults.get(player.getPosition()));
}
}
private static int findViewerPosition(Players players, String viewerName){
return players.getPlayers().stream()
.filter(player -> player.getName().equals(viewerName))
.map(Player::getPosition)
.findFirst()
.orElse(-1);
}
public static void printResult(Players players, List<String> kindOfResults) {
final String viewerName = InputView.inputViewerName();
System.out.println("\n실행결과");
if ("all".equals(viewerName)) {
printAllResult(players, kindOfResults);
return;
}
int result = findViewerPosition(players,viewerName);
System.out.println(kindOfResults.get(result));
}
}