-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathOutputView.java
More file actions
30 lines (26 loc) · 880 Bytes
/
OutputView.java
File metadata and controls
30 lines (26 loc) · 880 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
package view;
import domain.RacingCar;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
public class OutputView {
private static final String RACING_MARK="-";
private static final String WINNER_MESSAGE="최종 우승자 : ";
public void printRace(Map<RacingCar, Integer> cars){
for (RacingCar racingCar : cars.keySet()) {
System.out.print(racingCar.getName()+" : ");
for (int i=0; cars.get(racingCar)>i; i++){
System.out.print(RACING_MARK);
}
System.out.println();
}
}
public void printResult(List<String> winners){
System.out.print(WINNER_MESSAGE);
StringJoiner joiner = new StringJoiner(", ");
for (String winner : winners) {
joiner.add(winner);
}
System.out.println(joiner.toString());
}
}