-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathView.java
More file actions
30 lines (24 loc) · 813 Bytes
/
View.java
File metadata and controls
30 lines (24 loc) · 813 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 racingcar;
public class View {
public void racingCurrentView(Car car) {
System.out.println(car.checkCarName() + " : " + "-".repeat(car.checkMovement()));
}
public void winner(Car[] cars) {
int max = cars[0].checkMovement();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < cars.length; i++) {
if (max < cars[i].checkMovement()) {
max = cars[i].checkMovement();
}
}
for (int j = 0; j < cars.length; j++) {
if (cars[j].checkMovement() == max) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(cars[j].checkCarName());
}
}
System.out.println("최종 우승자 : " + sb);
}
}