diff --git a/docs/README.md b/docs/README.md index fd44069597..85e6208157 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,20 +1,161 @@ -# User Guide +# User Guide ## Features -### Feature 1 -Description of feature. +### 1. Add Todo +Add a todo task to your task list. + +### 2. Add Deadline +Add a deadline task to your task list with relevant time. + +### 3. Add Event +Add an event to your task list with relevant time. + +### 4. Mark task as Done +Mark a task in your task list as done. + +### 5. List all tasks +List out all tasks in your task list in order. + +### 6. Delete task +Delete a task from your task list. + +### 7. Find task +Find tasks containing any form of a keyword. + +### 8. Save task list +Save your task list to a .txt file. + +### 8. Save task list +Load your task list from a .txt file. + ## Usage -### `Keyword` - Describe action +### `todo ` - Add a Todo task + +Add a Todo task to your task list. + +Example of usage: + +`todo read book` + +Expected outcome: + +`____________________________________________________________ +Got it. I've added this task: ` +`[T][✗] read book` +`Now you have 1 tasks in the list.` +`____________________________________________________________` + +### `event /at ` - Add an Event + +Add an Event task to your task list with relevant time. + +Example of usage: + +`event meeting /10am` + +Expected outcome: + +`____________________________________________________________ +Got it. I've added this task: ` +`[E][✘] meeting (10am)` +`Now you have 2 tasks in the list.` +`____________________________________________________________` + +### `deadline /by ` - Add a Deadline + +Add a Deadline task to your task list. + +Example of usage: + +`deadline Assignment 2 /Monday 2359` + +Expected outcome: + +`____________________________________________________________ +Got it. I've added this task: ` +`[D][✗] Assignment 2 (Monday 2359)` +`Now you have 3 tasks in the list.` +`____________________________________________________________` + + + -Describe action and its outcome. -Example of usage: -`keyword (optional arguments)` +### `done ` - Mark task as done + +Mark a task in your task list as done. + +Example of usage: + +`done 1` + +Expected outcome: + +`____________________________________________________________ +Nice! I've marked this task as done: ` +`[[T][✓] read book` +`____________________________________________________________` + +### `list` - List all tasks + +List all tasks in your task list. + +Example of usage: + +`list` + +Expected outcome: + +`____________________________________________________________ +Here are the tasks in your list: ` +`1. [T][✓] read book` +`2. [E][✘] meeting (10am)` +`3. [D][✘] Assignment 2 (Monday 2359)` +`____________________________________________________________` + +### `delete ` - Delete a task + +Delete a task from your task list. + +Example of usage: + +`delete 1` Expected outcome: -`outcome` +`____________________________________________________________` +`Removed: [T][✓] read book` +`Now you have 2 task(s) in your list` +`____________________________________________________________` + +### `find ` - Find tasks + +Find tasks with matching keyword. + +Example of usage: + +`find read` + +Expected outcome: + + +`Here are the matching tasks in your list: ` +`1. [D][✘] Go through lecture readings (Tuesday before lecture)` +`2. [E][✘] Reading habit fair (Tuesday 10pm)` + +### `save` - Save task list + +Save task list to .txt file. + +Example of usage: + +`save` + +Expected outcome: + + `Successfully saved to file!` + diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java new file mode 100644 index 0000000000..379a6ab909 --- /dev/null +++ b/src/main/java/Deadline.java @@ -0,0 +1,11 @@ +public class Deadline extends Task { + public Deadline(String description, String deadline) { + super(description); + this.date=deadline; + } + + @Override + public String toString() { + return "[D]" + super.toString() + "(" + this.date + ")"; + } +} diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 5d313334cc..e173f4f28c 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,10 +1,244 @@ +//package duke; + +//import duke.task.Deadline; +//import duke.task.Event; +//import duke.task.Task; +//import duke.task.ToDo; + +import java.io.FileWriter; +import java.util.Scanner; +import java.lang.String; +import java.util.ArrayList; +import java.io.IOException; +import java.io.File; +import java.io.FileWriter; + public class Duke { - public static void main(String[] args) { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); + public final static String FILE_DIR = "data"; + public final static String FILE_PATH = "data/data.txt"; + public static int listCount = 0; + public static ArrayList list = new ArrayList<>(); + + + public static void main(String[] args) throws IOException { + //Generates a greeting + greet(); + fileLoad(); + request(); } + + public static void bidGoodbye(){ + System.out.println("Bye. Hope to see you again soon!"); + } + + public static void printList(){ + int i; + for (i = 0; i < listCount; i++) { + System.out.println((i+1) + "." + list.get(i)); + } + } + + public static void markDone(String word) { + try { + int num = Integer.parseInt(word); + Task task = list.get(num); + task.isDone = true; + System.out.println("Nice! I've marked this task as done:"); + System.out.println("[✓] " + list.get(num - 1).description); + System.out.println("Now you have " + listCount + " tasks in the list"); + }catch (ArrayIndexOutOfBoundsException e) { + System.out.println("Cannot find the task"); + } + } + + public static void todo(String line) { + try { + Task newTask = new ToDo(line); + newTask.type = 'T'; + list.add(newTask); + listCount++; + System.out.println("Got it. I've added this task:"); + System.out.println(line); + System.out.println("Now you have " + listCount + " tasks in the list"); + + }catch(ArrayIndexOutOfBoundsException e){ + System.out.println("____________________________________________________________\n" + + "0x00002639 OOPS!!! The description of a todo cannot be empty."); + System.out.println("____________________________________________________________\n"); + } + } + + public static void Event(String line){ + try{ + int index = line.indexOf('/'); + Task newTask = new Event(line.substring(0, index), line.substring(index + 1)); + newTask.type = 'E'; + list.add(newTask); + System.out.println("Got it. I've added this task: "+list.get(listCount).description); + listCount++; + System.out.println("Now you have " + listCount + " tasks in the list"); + + }catch(ArrayIndexOutOfBoundsException e){ + System.out.println("____________________________________________________________\n" + + "☹ OOPS!!! The description of an event cannot be empty."); + System.out.println("____________________________________________________________\n"); + } + } + + public static void Deadline(String line) { + try { + int index = line.indexOf('/'); + Task newTask = new Deadline(line.substring(0, index), line.substring(index + 1)); + newTask.type = 'D'; + list.add(newTask); + System.out.println("Got it. I've added this task:"); + System.out.println(list.get(listCount).description); + listCount++; + System.out.println("Now you have " + listCount + " tasks in the list"); + + }catch(ArrayIndexOutOfBoundsException e){ + System.out.println("____________________________________________________________\n" + + "☹ OOPS!!! The description of a deadline cannot be empty."); + System.out.println("____________________________________________________________\n"); + } + } + + public static void Delete(String taskNumber){ + int num = Integer.parseInt(taskNumber); + Task task = list.get(num-1); + list.remove(num-1); + System.out.println("Removed: " + task.description); + System.out.println("Now you have: " + list.size() + " task(s) in your list!"); + } + + public static void Find (String description){ + int findCount = 0; + System.out.println(" Here are the matching tasks in your list: "); + for(int i =0; i