-
Notifications
You must be signed in to change notification settings - Fork 726
/
Copy pathLadderController.java
43 lines (33 loc) · 1.32 KB
/
LadderController.java
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
package ladder.controller;
import ladder.domain.Ladder;
import ladder.domain.Results;
import ladder.domain.Users;
import ladder.service.LadderResultService;
import ladder.view.InputView;
import ladder.view.OutputView;
public class LadderController {
private static LadderController ladderController;
private final LadderResultService ladderResultService;
private LadderController(LadderResultService ladderResultService)
{
this.ladderResultService = ladderResultService;
}
public static LadderController getInstance() {
if (ladderController == null) {
ladderController = new LadderController(LadderResultService.getInstance());
}
return ladderController;
}
public void run() {
Users users = Users.from(InputView.getNames());
Results results = Results.of(InputView.getResult(), users.getUserCount());
Ladder ladder = Ladder.of(users.getUserCount(), InputView.getHeight());
OutputView.printLadder(users.getUserList(), ladder.getLines(), results.getResults());
boolean isEnd = false;
while (!isEnd) {
isEnd = OutputView
.printLadderResult(ladderResultService.getLadderResult(InputView.getTargetPlayer(), users.getUserList()
, ladder, results.getResults()));
}
}
}