-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathApplication.java
More file actions
33 lines (27 loc) · 1.08 KB
/
Application.java
File metadata and controls
33 lines (27 loc) · 1.08 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
package racingcar;
import java.util.ArrayList;
import java.util.List;
import static camp.nextstep.edu.missionutils.Console.readLine;
public class Application {
public static void main(String[] args) {
System.out.println("경주할 자동차 이름을 입력하세요. (이름은 쉼표(,) 기준으로 구분)");
String[] names = readLine().split(",");
List<Car> cars = new ArrayList<>();
for (String name: names) {
cars.add(new Car(name));
}
System.out.println("시도할 횟수는 몇 회인가요?");
int count = Integer.parseInt(readLine());
System.out.println("실행 결과");
for (int i = 0; i < count; i++) {
for (Car car: cars){
car.move();
System.out.println(car.getName() + " : " + car.getPositionToString());
}
System.out.println();
}
GameResult gameResult = new GameResult();
gameResult.getWinners();
System.out.print("최종 우승자 : " + String.join(", ") + gameResult.getWinners());
}
}