-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathLineController.java
More file actions
56 lines (48 loc) · 1.58 KB
/
Copy pathLineController.java
File metadata and controls
56 lines (48 loc) · 1.58 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
55
56
package subway.controller;
import java.util.List;
import subway.domain.constants.LineCommand;
import subway.service.RouteService;
import subway.service.SubwayService;
import subway.view.LineView;
public class LineController {
private final LineView lineView;
private final SubwayService subwayService;
private final RouteService routeService;
public LineController(LineView lineView, SubwayService subwayService, RouteService routeService) {
this.lineView = lineView;
this.subwayService = subwayService;
this.routeService = routeService;
}
public void run() {
lineView.printFunctions();
LineCommand function = lineView.enterFunction();
if (function.equals(LineCommand.ADD)) {
addLine();
}
if (function.equals(LineCommand.DELETE)) {
deleteLine();
}
if (function.equals(LineCommand.GET)) {
getLines();
}
}
public void addLines(List<String> lines) {
subwayService.addAll(lines);
}
private void addLine() {
String name = lineView.enterLineNameToAdd();
String head = lineView.enterHeadStation();
String tail = lineView.enterTailStation();
routeService.addRoute(name, head, tail);
subwayService.add(name);
lineView.printAddResult();
}
private void deleteLine() {
String name = lineView.enterLineNameToDelete();
subwayService.delete(name);
lineView.printDeleteResult();
}
private void getLines() {
lineView.printAllLines(subwayService.getAll());
}
}