forked from nus-cs2103-AY2223S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Duke.java
85 lines (74 loc) · 2.25 KB
/
Duke.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package duke;
//import javafx.application.Application;
//import javafx.scene.Scene;
//import javafx.scene.control.Button;
//import javafx.scene.control.ScrollPane;
//import javafx.scene.control.TextField;
//import javafx.scene.layout.AnchorPane;
//import javafx.scene.layout.VBox;
//import javafx.stage.Stage;
import java.util.ArrayList;
/**
* Duke is an interactive personal chat robot to keep track of user inputted tasks.
*
* @author Liu Han
*/
public class Duke {
private final static String PATH = "src/main/java/data/duke.txt";
private final Storage storage;
private TaskList tasks;
private final Ui ui;
// private ScrollPane scrollPane;
// private VBox dialogContainer;
// private TextField userInput;
// private Button sendButton;
// private Scene scene;
/**
* Duke Constructor
* @param filePath the file path where user would like to store the .txt file consisting of list of tasks
*/
public Duke(String filePath) {
this.ui = new Ui();
this.storage = new Storage(filePath);
try {
this.tasks = new TaskList(storage.loadData());
} catch (DukeException e) {
ui.showLoadingError();
this.tasks = new TaskList();
}
}
public static void main(String[] args) {
new Duke(PATH).run();
}
private void run() {
ui.showWelcome();
//storage.saveData(this.tasks);
//ui.farewell();
}
public String getResponse(String input) {
if (input.equals("bye")) {
storage.saveData(this.tasks);
}
return new Parser(this.tasks).parser(input);
}
// @Override
// public void start(Stage stage) {
// //Step 1. Setting up required components
//
// //The container for the content of the chat to scroll.
// scrollPane = new ScrollPane();
// dialogContainer = new VBox();
// scrollPane.setContent(dialogContainer);
//
// userInput = new TextField();
// sendButton = new Button("Send");
//
// AnchorPane mainLayout = new AnchorPane();
// mainLayout.getChildren().addAll(scrollPane, userInput, sendButton);
//
// scene = new Scene(mainLayout);
//
// stage.setScene(scene);
// stage.show();
// }
}