-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathOutput.java
More file actions
75 lines (64 loc) · 2.1 KB
/
Output.java
File metadata and controls
75 lines (64 loc) · 2.1 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package view;
import domain.Participant;
import java.util.ArrayList;
public class Output {
// 참여자 출력
public static void printParticipants(ArrayList<Participant> participants){
System.out.println("사다리 결과\n");
for(Participant p : participants){
System.out.print(" " + p.getName());
}
}
// 실행 결과 출력
public static void printResults(ArrayList<String> results){
for(String r : results){
System.out.print(" " + r);
}
System.out.println();
System.out.println();
}
// 사다리 출력 1
public static void printLadder(ArrayList<ArrayList<Integer>> array2D) {
for (ArrayList<Integer> row : array2D) {
printRow(row);
}
}
// 사다리 출력 2
private static void printRow(ArrayList<Integer> row) {
System.out.print(" |");
for (int val : row) {
printRowLadder(val);
System.out.print("|");
}
System.out.println();
}
// 사다리 출력 3
private static void printRowLadder(int val) {
if(val == 1)
System.out.print("-----");
if(val == 0)
System.out.print(" ");
}
// 개별 참가자의 결과 출력 1
public static void printResultForParticipant(ArrayList<Participant> participants, String name) {
System.out.println("실행 결과");
for (Participant p : participants) {
printResultForParticipant2(p, name);
}
System.out.println();
}
// 개별 참가자의 결과 출력 2
public static void printResultForParticipant2 (Participant p, String name){
if (p.getName().equalsIgnoreCase(name)) {
System.out.println(p.getResult());
}
}
// 모든 참가자의 결과 출력
public static void printAllResults(ArrayList<Participant> participants) {
System.out.println("실행 결과");
for (Participant p : participants) {
System.out.println(p.getName() + " : " + p.getResult());
}
System.out.println();
}
}