byefinddelete tododeadlineeventliststatshidonebyeExit the program.
Input instruction:
bye
findFind the expected task with given keyword.
Input instruction:
find + keyword
Example of usage: find homework
deleteDelete the expected task with given index in the task list.
Input instruction:
delete + index
Example of usage: delete 1
todoCreate a task that you are going to do and store in the tasklist.
Input instruction:
todo + task content
Example of usage: todo play games
deadlineCreate a task with a deadline
Input instruction:
deadline + task content + /by + YYYY-MM-DD
Example of usage: deadline finish homework /by 2020-05-12
eventCreate an event
Input instruction:
event + task content + /at + YYYY-MM-DD
Example of usage: event celebrate holiday /at 2020-05-12
listShow the list of tasks
Input instruction:
list
Example of usage: list
statsShow the number of task completed
Input instruction:
stats
Example of usage: stats
hiGreet the bot and it will greet you back
Input instruction:
hi
Example of usage: hi
doneMark your task done
Input instruction:
done + index
Example of usage: done 1
| Action | Format, Examples |
|---|---|
| Find Task | find keyword e.g., find homework |
| Delete Task | delete indexe.g., delete 1 |
| Todo Task | todo description e.g., doto play games |
| Deadline Task | deadline description /by YYYY-MM-DD e.g., deadline finish homework /by 2020-05-12 |
| Event Task | event description /at YYYY-MM-DD e.g., event celebrate holiday /at 2020-05-12 |
| List Task | list |
| Stats | stats |
| Done | done index e.g., done 1 |
| Bye | bye |
//@@author dcchan98-reused //Reused from https://github.com/dcchan98/ip/blob/master/src/main/java/Storage.java with minor modification
public void writeToFile(Task myTask, int todoNum) {
createToDo("ToDo/item" + todoNum + ".txt");
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("ToDo/item" + todoNum + ".txt"));
out.writeObject(myTask);
} catch (IOException e) {
e.printStackTrace();
}
} public Task readFromFile(String fileDir) {
Task myTask = null;
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileDir));
myTask = (Task) in.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return myTask;
} public void updateDirectory(TaskList myTaskList) {
// deleting all files in directory
File dir = new File("ToDo");
File[] myItems = dir.listFiles();
for (File child : myItems) {
if (child.toString().substring(0, 9).equals("ToDo/item")) {
Path path = FileSystems.getDefault().getPath(child.toString());
try {
Files.delete(path);
} catch (NoSuchFileException x) {
System.err.format("%s: no such" + " file or directory%n", path);
} catch (IOException x) {
System.err.println(x);
}
}
}
// repopulating directory with that in arraylist taks
for (int i = 0; i < myTaskList.getTasks().size(); i++) {
writeToFile(myTaskList.getTasks().get(i), i);
}
} //@@author dcchan98-reused