-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathGameController.java
More file actions
40 lines (30 loc) · 1.14 KB
/
GameController.java
File metadata and controls
40 lines (30 loc) · 1.14 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
package mission.controller;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;
import static mission.util.RetyrUtil.read;
import java.util.List;
import mission.domain.Players;
import mission.dto.PlayerInfoDto;
import mission.dto.PlayerNamesDto;
import mission.view.InputView;
import mission.view.OutputView;
import mission.domain.NumberGenerator;
public class GameController {
private final NumberGenerator numberGenerator;
InputView inputView = InputView.getInstance();
public GameController(NumberGenerator numberGenerator) {
this.numberGenerator = numberGenerator;
}
public void start() {
Players players = read(this::generatePlayer);
OutputView.printStart();
}
private Players generatePlayer() {
PlayerNamesDto playerNamesDto = read(InputView::scanPlayerNames);
List<PlayerInfoDto> playerInfoDtos = inputView.scanBettingMoneys(
playerNamesDto.getPlayerNames());
return playerInfoDtos.stream()
.map(PlayerInfoDto::toPlayer)
.collect(collectingAndThen(toList(), Players::from));
}
}