Skip to content

Commit 618755d

Browse files
authored
Merge pull request #8 from raymondge/JAR-released
Finalise the rest of the task
2 parents b505e20 + 97e127f commit 618755d

27 files changed

+407
-292
lines changed

TaskList/Task0.txt

0 Bytes
Binary file not shown.

TaskList/Task1.txt

4 Bytes
Binary file not shown.

TaskList/Task2.txt

1 Byte
Binary file not shown.

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ repositories {
1111

1212

1313
dependencies {
14+
implementation 'junit:junit:4.12'
1415
String javaFxVersion = '11'
1516

1617
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
@@ -46,11 +47,11 @@ test {
4647
}
4748

4849
application {
49-
mainClassName = "seedu.duke.Duke"
50+
mainClassName = "Launcher"
5051
}
5152

5253
shadowJar {
53-
archiveBaseName = "duke"
54+
archiveBaseName = "Launcher"
5455
archiveClassifier = null
5556
}
5657

docs/README.md

Lines changed: 141 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,151 @@
1-
# User Guide
1+
# User Guide for duke bot
22

33
## Features
44

5-
### Feature 1
6-
Description of feature.
5+
### Say bye to duke `bye`
76

8-
## Usage
7+
Exit the program.
98

10-
### `Keyword` - Describe action
9+
Input instruction:
1110

12-
Describe action and its outcome.
11+
`bye`
1312

14-
Example of usage:
13+
### Find a task `find`
1514

16-
`keyword (optional arguments)`
15+
Find the expected task with given index in the task list.
1716

18-
Expected outcome:
17+
Input instruction:
1918

20-
`outcome`
19+
`find` + `index`
20+
21+
Example of usage: find 1
22+
23+
### Delete a task `delete`
24+
25+
Delete the expected task with given index in the task list.
26+
27+
Input instruction:
28+
29+
`delete` + `index`
30+
31+
Example of usage: delete 1
32+
33+
### Create a todo task `todo`
34+
35+
Create a task that you are going to do and store in the tasklist.
36+
37+
Input instruction:
38+
39+
`todo` + `task content`
40+
41+
Example of usage: todo play games
42+
43+
### Create a deadline task `deadline`
44+
45+
Create a task with a deadline
46+
47+
Input instruction:
48+
49+
`deadline` + `task content` + `/by` + `YYYY-MM-DD`
50+
51+
Example of usage: deadline finish homework /by 2020-05-12
52+
53+
### Create a event task `event`
54+
55+
Create an event
56+
57+
Input instruction:
58+
59+
`event` + `task content` + `/at` + `YYYY-MM-DD`
60+
61+
Example of usage: event celebrate holiday /at 2020-05-12
62+
63+
### List your tasks `list`
64+
65+
Show the list of tasks
66+
67+
Input instruction:
68+
69+
`list`
70+
71+
Example of usage: list
72+
73+
### Find out statistics `stats`
74+
75+
Show the number of task completed
76+
77+
Input instruction:
78+
79+
`stats`
80+
81+
Example of usage: stats
82+
83+
### Says hi to duke `hi`
84+
85+
Greet the bot and it will greet you back
86+
87+
Input instruction:
88+
89+
`hi`
90+
91+
Example of usage: hi
92+
93+
### Mark your task done `done`
94+
95+
Mark your task done
96+
97+
Input instruction:
98+
99+
`done` + `index`
100+
101+
Example of usage: done 1
102+
103+
//@@author dcchan98-reused
104+
//Reused from https://github.com/dcchan98/ip/blob/master/src/main/java/Storage.java with minor modification
105+
106+
public void writeToFile(Task myTask, int todoNum) {
107+
108+
createToDo("ToDo/item" + todoNum + ".txt");
109+
110+
try {
111+
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("ToDo/item" + todoNum + ".txt"));
112+
out.writeObject(myTask);
113+
} catch (IOException e) {
114+
e.printStackTrace();
115+
}
116+
}
117+
public Task readFromFile(String fileDir) {
118+
Task myTask = null;
119+
try {
120+
ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileDir));
121+
myTask = (Task) in.readObject();
122+
} catch (IOException | ClassNotFoundException e) {
123+
e.printStackTrace();
124+
}
125+
return myTask;
126+
127+
}
128+
public void updateDirectory(TaskList myTaskList) {
129+
130+
// deleting all files in directory
131+
File dir = new File("ToDo");
132+
File[] myItems = dir.listFiles();
133+
for (File child : myItems) {
134+
if (child.toString().substring(0, 9).equals("ToDo/item")) {
135+
Path path = FileSystems.getDefault().getPath(child.toString());
136+
try {
137+
Files.delete(path);
138+
} catch (NoSuchFileException x) {
139+
System.err.format("%s: no such" + " file or directory%n", path);
140+
} catch (IOException x) {
141+
System.err.println(x);
142+
}
143+
}
144+
}
145+
146+
// repopulating directory with that in arraylist taks
147+
for (int i = 0; i < myTaskList.getTasks().size(); i++) {
148+
writeToFile(myTaskList.getTasks().get(i), i);
149+
}
150+
}
151+
//@@author dcchan98-reused

docs/UI.PNG

148 KB
Loading

src/main/java/Deadline.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,36 @@
22
import java.time.format.DateTimeFormatter;
33

44
/**
5-
* Encapsulates data for a deadline task.
5+
* A deadline task that comprises a deadline task description, date and whether it is done.
66
*/
77

88
public class Deadline extends Task {
99

1010
protected LocalDate time;
1111

12+
/**
13+
* Create a deadline task.
14+
* @param description of task.
15+
* @param isDone done status of task.
16+
* @param time of task.
17+
*/
1218
public Deadline(String description, boolean isDone, LocalDate time) {
1319
super(description, isDone);
1420
this.time = time;
1521
}
1622

23+
/**
24+
* Returns the deadline date.
25+
* @return deadline date.
26+
*/
1727
public String getDate() {
1828
return time.format(DateTimeFormatter.ofPattern("MMM d yyyy"));
1929
}
30+
31+
/**
32+
* Returns the String description for deadline.
33+
* @return String description.
34+
*/
2035
@Override
2136
public String toString() {
2237
return "[D]" + super.toString() + " (by: " + getDate() + ")";

src/main/java/DialogBox.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public class DialogBox extends HBox {
2323
@FXML
2424
private ImageView displayPicture;
2525

26+
/**
27+
* Create a DialogBox.
28+
* @param text of Dialog.
29+
* @param img image of Dialog.
30+
*/
2631
private DialogBox(String text, Image img) {
2732
try {
2833
FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml"));
@@ -47,10 +52,16 @@ private void flip() {
4752
setAlignment(Pos.TOP_LEFT);
4853
}
4954

55+
/**
56+
* Static method to get User Dialog with text and image.
57+
*/
5058
public static DialogBox getUserDialog(String text, Image img) {
5159
return new DialogBox(text, img);
5260
}
5361

62+
/**
63+
* Static method to get Duke Dialog with text and image with flipped position.
64+
*/
5465
public static DialogBox getDukeDialog(String text, Image img) {
5566
var db = new DialogBox(text, img);
5667
db.flip();

0 commit comments

Comments
 (0)