-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathRacingController.java
More file actions
44 lines (36 loc) · 1.1 KB
/
RacingController.java
File metadata and controls
44 lines (36 loc) · 1.1 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
package controller;
import domain.Cars;
import domain.TryCount;
import view.InputView;
import view.OutputView;
import java.io.IOException;
import java.util.List;
public class RacingController {
public void run() throws IOException {
Cars cars = new Cars(createCars());
TryCount tryCount = new TryCount(setTryCount());
racingResult(tryCount, cars);
findWinners(cars);
}
// 자동차 정보 입력
private List<String> createCars() throws IOException {
return InputView.getCarName();
}
// 시도 횟수 입력
private int setTryCount() throws IOException {
return InputView.getTryCount();
}
// 시행 결과 출력
private void racingResult(TryCount tryCount, Cars cars) {
OutputView.printRacingResult();
while(tryCount.isPlayable()) {
tryCount.decreaseTryCount();
cars.moveCars();
OutputView.printRacingStatus(cars.getCars());
}
}
// 우승자 출력
private void findWinners(Cars cars) {
OutputView.printRacingWinner(cars.findWinnerName());
}
}