-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathRacingCarController.java
More file actions
54 lines (45 loc) · 2.02 KB
/
RacingCarController.java
File metadata and controls
54 lines (45 loc) · 2.02 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
42
43
44
45
46
47
48
49
50
51
52
53
54
package racingcar.Controller;
import racingcar.Model.Cars;
import racingcar.Service.*;
import racingcar.View.InputView;
import racingcar.View.OutputView;
import java.util.List;
public class RacingCarController {
private final ClassificationService classificationService;
private final MovementService movementService;
private final RandomService randomService;
private final InputView inputView;
private final OutputView outputView;
private final NameValidationService nameValidationService;
private final NameSplitterService nameSplitterService;
private final ParseService parseService;
private final ResultService resultService;
private final GameService gameService;
private final CreateCarService createCarService;
public RacingCarController() {
this.classificationService = new ClassificationService();
this.movementService = new MovementService();
this.randomService = new RandomService();
this.inputView = new InputView();
this.outputView = new OutputView();
this.nameValidationService = new NameValidationService();
this.nameSplitterService = new NameSplitterService();
this.parseService = new ParseService();
this.resultService = new ResultService();
this.gameService = new GameService(randomService, classificationService, movementService);
this.createCarService = new CreateCarService();
}
public void run() {
List<String> input = inputView.input();
List<String> carNames =
nameValidationService.validateName(nameSplitterService.nameSplit(input.getFirst()));
Cars carRacers = createCarService.crateCar(carNames);
int roundCount = parseService.parseInt(input.getLast());
for (int round = 0; round < roundCount; round++) {
gameService.gameRound(carRacers);
outputView.output_round(carRacers);
}
List<String> winnerNames = resultService.findWinners(carRacers);
outputView.output_winner(winnerNames);
}
}