-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathOutputView.java
More file actions
41 lines (34 loc) · 1.05 KB
/
OutputView.java
File metadata and controls
41 lines (34 loc) · 1.05 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
package racingcar.view;
import racingcar.model.Car;
import java.util.List;
public class OutputView {
public static void printHead(){
System.out.println();
System.out.println("실행 결과");
}
public static void printScore(List<Car> cars){
for(Car car : cars) {
printCarScore(car);
}
System.out.println();
}
public static void printWinners(List<Car> winners){
StringBuilder winnerNames = new StringBuilder("최종 우승자 : ");
for(Car car : winners){
winnerNames.append(car.getName()).append(", ");
}
int length = winnerNames.length();
String result = winnerNames.substring(0, length - 2);
System.out.print(result);
}
public static void printCarScore(Car car){
System.out.print(car.getName()+" : ");
printCarPosition(car);
System.out.println();
}
public static void printCarPosition(Car car){
for(int i=0; i<car.getPosition(); i++){
System.out.print("-");
}
}
}