-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathMainController.java
More file actions
35 lines (26 loc) · 1.12 KB
/
MainController.java
File metadata and controls
35 lines (26 loc) · 1.12 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
package nextstep.ladder.controller;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import nextstep.ladder.model.Ladder;
import nextstep.ladder.model.LadderHeight;
import nextstep.ladder.model.Name;
import nextstep.ladder.model.PersonCount;
import nextstep.ladder.model.RandomTrueOrFalse;
import nextstep.ladder.view.InputView;
import nextstep.ladder.view.OutputView;
public class MainController {
public static void main(String[] args) {
InputView inputView = new InputView();
String namesText = inputView.inputUserNames();
List<Name> names = Arrays.stream(namesText.split(","))
.map(Name::new)
.collect(Collectors.toList());
PersonCount countOfPerson = new PersonCount(names.size());
String heightOfLadderText = inputView.inputHeightOfLadder();
LadderHeight heightOfLadder = new LadderHeight(Integer.parseInt(heightOfLadderText));
Ladder ladder = new Ladder(heightOfLadder, countOfPerson, new RandomTrueOrFalse());
OutputView outputView = new OutputView();
outputView.print(ladder, names);
}
}