-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathController.java
More file actions
34 lines (30 loc) · 868 Bytes
/
Controller.java
File metadata and controls
34 lines (30 loc) · 868 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
31
32
33
34
package controller;
import java.util.ArrayList;
import java.util.List;
import model.Car;
import model.Race;
import view.Input;
import view.Output;
public class Controller {
private List<Car> createCars() {
while (true) {
try {
String[] names = Input.getCarName();
List<Car> cars = new ArrayList<>();
for (String carName : names) {
cars.add(new Car(carName));
}
return cars;
} catch (IllegalArgumentException e){
System.out.println("[ERROR] " + e.getMessage());
}
}
}
public void play() {
List<Car> cars = createCars();
int round = Input.getRound();
Race race = new Race(cars, round);
race.start();
Output.printWinner(race.getWinner());
}
}