-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathOutputView.java
More file actions
36 lines (28 loc) · 992 Bytes
/
OutputView.java
File metadata and controls
36 lines (28 loc) · 992 Bytes
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
package ladder.view.output;
import ladder.domain.ladder.Ladder;
import ladder.domain.ladder.Line;
import ladder.domain.ladder.Point;
import ladder.domain.player.Players;
public class OutputView {
public static void printResult(Players players, Ladder ladder) {
System.out.println("\n실행결과\n");
printPlayerNames(players);
printLadder(ladder);
}
private static void printPlayerNames(Players players) {
players.getPlayers()
.forEach(p -> System.out.printf("%-6s", p.getName()));
System.out.println();
}
private static void printLadder(Ladder ladder) {
ladder.getLines().forEach(OutputView::printLine);
}
private static void printLine(Line line) {
StringBuilder sb = new StringBuilder();
for (Point point : line.getPoints()) {
sb.append("|").append(point.hasLine() ? "-----" : " ");
}
sb.append("|");
System.out.println(sb);
}
}