-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathResultView.java
More file actions
46 lines (38 loc) · 1.19 KB
/
ResultView.java
File metadata and controls
46 lines (38 loc) · 1.19 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
package ladder.view;
import ladder.domain.Line;
import ladder.domain.Lines;
import java.util.Arrays;
public class ResultView {
private LinePrinter printer;
private final String[] participants;
private final Lines lines;
public ResultView(LinePrinter printer, String[] participants, Lines lines) {
this.printer = printer;
this.participants = participants;
this.lines = lines;
}
public void showResult() {
System.out.println("");
System.out.println("실행 결과");
printParticipants();
printResult();
}
private void printParticipants() {
Arrays.stream(participants)
.forEach(name -> System.out.print(name + " "));
System.out.println("");
}
private void printResult() {
for (Line line : lines.getLines()) {
printLadderByOneLine(line);
System.out.println("");
}
}
private void printLadderByOneLine(Line line) {
int rowLineNumber = participants.length - 1;
System.out.print("|");
for (int index = 0; index < rowLineNumber; index++) {
printer.printRefactoring(line.isPosition(index));
}
}
}