diff --git a/data/output.txt b/data/output.txt new file mode 100644 index 000000000..a1391eb83 --- /dev/null +++ b/data/output.txt @@ -0,0 +1,3 @@ +T | 0 | add book +D | 1 | bye | 1040 +T | 0 | see book diff --git a/docs/README.md b/docs/README.md index 8077118eb..1ab36f660 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,29 +1,152 @@ # User Guide +toDoList is a Command Line Interface (CLI) application that +helps you to manage your tasks. + +## Contents of User Guide +- Features + 1. [`list` - List all tasks](#listing-all-tasks) + 2. [`todo` - Create a todo task](#adding-a-todo) + 3. [`deadline` - Create a deadline task](#adding-a-deadline) + 4. [`event` - Create an event task](#adding-an-event) + 5. [`done` - Mark task as done](#mark-as-done) + 6. [`delete` - Delete task from list](#delete-task) + 7. [`find` - Find tasks based on keyword](#find-task) + 8. [`bye` - Exit program](#exit-program) +- Command Summary ## Features +toDoList supports 3 types of tasks: `To-Do`, `Deadline` and `Event`. + +### Listing all tasks + +Shows a list of all tasks. -### Feature-ABC +Format: `list` + +Example of usage: +``` +list +``` +Expected outcome: +``` + Here are the tasks in your list: + 1.[T][ ] add book + 2.[E][X] see book (at: 29/09/21 2359) + 3.[D][ ] submit work (by: 30/10/21 1800) +``` -Description of the feature. +### Adding a Todo +Adds a Todo task -### Feature-XYZ +Format: `todo ` -Description of the feature. +Example of usage: +``` +todo add book +``` +Expected outcome: +``` + Got it. I've added this task: + [T][ ] add book + Now you have 6 tasks in the list. +``` -## Usage +### Adding a Deadline +Adds a Deadline task, followed by date -### `Keyword` - Describe action +Format: `deadline /by ` -Describe the action and its outcome. +Example of usage: +``` +deadline finish assignment /by 29/09/21 2359 +``` +Expected outcome: +``` + Got it. I've added this task: + [D][ ] finish assignment (by: 29/09/21 2359) + Now you have 7 tasks in the list. +``` -Example of usage: +### Adding an Event +Adds an Event task, followed by date -`keyword (optional arguments)` +Format: `event /at ` +Example of usage: +``` +event birthday party /at 30/10/21 1800 +``` Expected outcome: +``` + Got it. I've added this task: + [E][ ] birthday party (at: 30/10/21 1800) + Now you have 8 tasks in the list. +``` + +### Mark as done +Marks a task as done -Description of the outcome. +Format: `done ` +Example of usage: ``` -expected output +done 3 ``` +Expected outcome: +``` + Nice! I've marked this task as done: + [D][X] finish assignment (by: 29/09/21 2359) +``` + +### Delete task +Deletes a task from the list. + +Format: `delete ` + +Example of usage: +``` +delete 2 +``` +Expected outcome: +``` + Noted. I've removed this task: + [E][ ] birthday party (at: 30/10/21 1800) + Now you have 3 tasks in the list. +``` + +### Find task +Finds tasks given keyword + +Format: `find ` + +Example of usage: +``` +find book +``` +Expected outcome: +``` + Here are the matching tasks in your list: + 1.[D][ ] throw book (by: 01/01/22) + 2.[T][ ] buy new book +``` + + +### Exit program +Exits from toDoList. + +Format: `bye` + +## Command Summary + +|Commands |Format, Examples | +| ---- | ---- | +|**List** | `list` | +|**Todo** | `todo `
eg: `todo add book` | +|**Deadline**| `deadline /by `
eg: `deadline finish assignment /by 29/09/21 2359`| +|**Event** | `event /at `
eg: `event birthday party /at 30/10/21 1800` | +|**Done** | `done `
eg: `done 3` | +|**Delete** | `delete `
eg: `delete 2` | +|**Find** | `find `
eg: `find book` | +|**Bye** | `bye` | + + diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java deleted file mode 100644 index 5d313334c..000000000 --- a/src/main/java/Duke.java +++ /dev/null @@ -1,10 +0,0 @@ -public class Duke { - public static void main(String[] args) { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); - } -} diff --git a/src/main/java/duke/DukeException.java b/src/main/java/duke/DukeException.java new file mode 100644 index 000000000..f09d58afb --- /dev/null +++ b/src/main/java/duke/DukeException.java @@ -0,0 +1,5 @@ +package duke; + +public class DukeException extends Exception { + +} \ No newline at end of file diff --git a/src/main/java/duke/command/Duke.java b/src/main/java/duke/command/Duke.java new file mode 100644 index 000000000..98b7e88df --- /dev/null +++ b/src/main/java/duke/command/Duke.java @@ -0,0 +1,15 @@ +package duke.command; + +import duke.task.TaskManager; + +import java.util.Scanner; + +public class Duke { + + public static void main(String[] args) { + TaskManager taskManager = new TaskManager(); + Scanner scanner = new Scanner(System.in); + Ui ui = new Ui(taskManager, scanner); + ui.start(); + } +} diff --git a/src/main/java/duke/command/Ui.java b/src/main/java/duke/command/Ui.java new file mode 100644 index 000000000..24a55bda1 --- /dev/null +++ b/src/main/java/duke/command/Ui.java @@ -0,0 +1,48 @@ +package duke.command; + +import duke.data.Storage; +import duke.task.Parser; +import duke.task.TaskManager; + +import java.util.Scanner; + +public class Ui { + private TaskManager taskManager; + private Scanner scanner; + + private static final String LINE = " ____________________________________________________________\n"; + private static final String LOGO = "\n" + + " \n" + + " ,--. ,------. ,--. ,--. ,--. \n" + + ",-' '-.,---.| .-. \\ ,---.| | `--',---,-' '-. \n" + + "'-. .-| .-. | | \\ | .-. | | ,--( .-'-. .-' \n" + + " | | ' '-' | '--' ' '-' | '--| .-' `)| | \n" + + " `--' `---'`-------' `---'`-----`--`----' `--' \n" + + " \n"; + private static final String GREETINGS = LINE + + LOGO + + " Welcome to the toDoList Chatbot\n" + + " What would you like to do today?\n" + + LINE; + + public Ui(TaskManager taskManager, Scanner scanner) { + this.taskManager = taskManager; + this.scanner = scanner; + } + + /** + * Starts the program. + */ + public void start() { + Storage.loadData(); + System.out.println(GREETINGS); + boolean isExit = false; + while (!isExit) { + String input = scanner.nextLine(); + System.out.print(LINE); + isExit = Parser.parse(input); + System.out.print(LINE); + Storage.saveData(); + } + } +} diff --git a/src/main/java/duke/data/Storage.java b/src/main/java/duke/data/Storage.java new file mode 100644 index 000000000..3f0312ae5 --- /dev/null +++ b/src/main/java/duke/data/Storage.java @@ -0,0 +1,129 @@ +package duke.data; + +import duke.task.Deadline; +import duke.task.Event; +import duke.task.Task; +import duke.task.TaskManager; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Scanner; + +public class Storage { + + private static final String PATH_NAME = "data/output.txt"; + private static final String FILE_CREATION_ERROR = "Error in creating file"; + private static final String SEPARATOR = " | "; + + /** + * Creates file inside its directory. + */ + public static void createFile(){ + try { + Path path = Paths.get(PATH_NAME); + Files.createDirectories(path.getParent()); + } catch (IOException e) { + System.out.println(FILE_CREATION_ERROR); + } + } + + /** + * Reads content from file and adds into TaskList. + * + * @param filePath Path where file is read from. + * @throws FileNotFoundException If file not found. + */ + public static void readFromFile(String filePath) throws FileNotFoundException { + File file = new File(filePath); + Scanner scanner = new Scanner(file); + while (scanner.hasNext()) { + String line = scanner.nextLine(); + String[] details = line.split("\\|"); + String taskType = details[0].trim(); + boolean isDone = details[1].trim().equals("1"); + String description = details[2].trim(); + String timing; + switch (taskType) { + case "T": + TaskManager.loadToDoFromFile(description, isDone); + break; + case "D": + timing = details[3].trim(); + TaskManager.loadDeadlineFromFile(description, timing, isDone); + break; + case "E": + timing = details[3].trim(); + TaskManager.loadEventFromFile(description, timing, isDone); + break; + } + } + } + + /** + * Appends to end of file. + * + * @param filePath Path to append file to. + * @param textToAppend Text to be appended. + * @throws IOException If an I/O exception has occurred. + */ + public static void appendToFile(String filePath, String textToAppend) throws IOException { + FileWriter fw = new FileWriter(filePath, true); // create a FileWriter in append mode + fw.write(textToAppend); + fw.close(); + } + + /** + * Writes to file. + * + * @param filePath Path to write file to. + * @throws IOException If an I/O exception has occurred. + */ + public static void writeToFile(String filePath) throws IOException { + String textToAppend; + FileWriter fw = new FileWriter(filePath, false); + fw.write(""); //clear the file + fw.close(); + for (Task task: TaskManager.taskList) { + String taskType = task.getIcon(); + String status = task.getStatus(); + String description = task.getDescription(); + String timing = task.getTime(); + + textToAppend = taskType + SEPARATOR + status + SEPARATOR + description; + if (task instanceof Event || task instanceof Deadline) { + textToAppend += SEPARATOR + timing; + } + textToAppend += "\n"; + appendToFile(filePath, textToAppend); + } + } + + /** + * Saves data into file. + */ + public static void saveData() { + try { + Path path = Paths.get(PATH_NAME); + Files.createDirectories(path.getParent()); + writeToFile(PATH_NAME); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Loads data from file. + */ + public static void loadData() { + try { + readFromFile(PATH_NAME); + } catch (FileNotFoundException e) { + createFile(); + } + } +} diff --git a/src/main/java/duke/task/Deadline.java b/src/main/java/duke/task/Deadline.java new file mode 100644 index 000000000..39c84be49 --- /dev/null +++ b/src/main/java/duke/task/Deadline.java @@ -0,0 +1,65 @@ +package duke.task; + +public class Deadline extends Task { + protected String timing; + + /** + * Constructs Deadline class given description and timing. + * + * @param description Description of deadline. + * @param by Due date of deadline. + */ + public Deadline(String description, String by) { + super(description); + this.timing = by; + } + + /** + * Constructs Deadline class given description, timing and status. + * + * @param description Description of deadline. + * @param by Due date of deadline. + * @param isDone Status of deadline. + */ + public Deadline(String description, String by, boolean isDone) { + this(description, by); + super.taskDone(isDone); + } + + /** + * Gets icon of deadline. + * + * @return Icon of deadline. + */ + public String getIcon() { + return "D"; + } + + /** + * Gets timing of deadline. + * + * @return timing of deadline. + */ + public String getTiming() { + return " (by: " + timing + ")"; + } + + /** + * Gets time of deadline. + * + * @return time of deadline. + */ + public String getTime() { + return timing; + } + + /** + * Returns string representing event. + * + * @return String representing event. + */ + @Override + public String toString() { + return "[" + getIcon() + "]" + super.toString() + getTiming(); + } +} \ No newline at end of file diff --git a/src/main/java/duke/task/Event.java b/src/main/java/duke/task/Event.java new file mode 100644 index 000000000..bc27a5bb7 --- /dev/null +++ b/src/main/java/duke/task/Event.java @@ -0,0 +1,66 @@ +package duke.task; + +public class Event extends Task { + protected String timing; + + /** + * Constructs Event class given description and timing. + * + * @param description Description of event. + * @param timing Timing of event. + */ + public Event(String description, String timing) { + super(description); + this.timing = timing; + } + + /** + * Constructs Event class given description, timing and status. + * + * @param description Description of event. + * @param timing Timing of event. + * @param isDone Status of event. + */ + public Event(String description, String timing, boolean isDone) { + this(description, timing); + super.taskDone(isDone); + } + + /** + * Gets icon of event. + * + * @return Icon of event. + */ + public String getIcon() { + return "E"; + } + + /** + * Gets timing of event. + * + * @return Timing of event. + */ + public String getTiming() { + return " (at: " + timing + ")"; + } + + /** + * Gets time of event. + * + * @return Time of event. + */ + public String getTime() { + return timing; + } + + /** + * Returns string representing event. + * + * @return String representing event. + */ + + @Override + public String toString() { + return "[" + getIcon() + "]" + super.toString() + getTiming(); + } +} diff --git a/src/main/java/duke/task/Parser.java b/src/main/java/duke/task/Parser.java new file mode 100644 index 000000000..ca40408cc --- /dev/null +++ b/src/main/java/duke/task/Parser.java @@ -0,0 +1,68 @@ +package duke.task; + +import duke.DukeException; + +public class Parser { + private static final String FAREWELL = " Bye. Hope to see you again soon!"; + private static final String TO_DO = "todo"; + private static final String DEADLINE = "deadline"; + private static final String EVENT = "event"; + private static final String BYE = "bye"; + private static final String LIST = "list"; + private static final String DONE = "done"; + private static final String DELETE = "delete"; + private static final String FIND = "find"; + private static final String ADD_SUCCESS = " Nice! I've marked this task as done: "; + private static final String DELETE_SUCCESS = " Noted. I've removed this task:"; + private static final String SHOW_MATCHES = " Here are the matching tasks in your list:"; + private static final String INVALID_COMMAND = " ☹ OOPS!!! I'm sorry, but I don't know what that means :-("; + private static final String INVALID_TASK_INDEX = " ☹ OOPS!!! The task's index should be an integer."; + + /** + * Parses input and executes respective command. + * + * @param input Input to be parsed. + * @return False if "bye" command not entered. + */ + public static boolean parse(String input) { + String[] params = input.split(" "); + String command = params[0]; + try { + switch (command) { + case BYE: + System.out.println(FAREWELL); + return true; + case LIST: + TaskManager.list(); + break; + case DONE: + int taskNumber = Integer.parseInt(params[1]); + System.out.println(ADD_SUCCESS); + TaskManager.setDone(params); + System.out.println(" " + TaskManager.getName(taskNumber)); + break; + case TO_DO: + case DEADLINE: + case EVENT: + TaskManager.add(input); + break; + case DELETE: + System.out.println(DELETE_SUCCESS); + TaskManager.deleteTask(params); + break; + case FIND: + System.out.println(SHOW_MATCHES); + String query = params[1]; + TaskManager.find(query); + break; + default: + System.out.println(INVALID_COMMAND); + } + } catch (DukeException e) { + System.out.println(" ☹ OOPS!!! The description of a " + command + " cannot be empty."); + } catch (NumberFormatException e) { + System.out.println(INVALID_TASK_INDEX); + } + return false; + } +} diff --git a/src/main/java/duke/task/Task.java b/src/main/java/duke/task/Task.java new file mode 100644 index 000000000..084b37d35 --- /dev/null +++ b/src/main/java/duke/task/Task.java @@ -0,0 +1,89 @@ +package duke.task; + +public class Task { + protected String description; + protected boolean isDone; + + /** + * Constructs task class given description. + * + * @param description Description of task. + */ + public Task(String description) { + this.description = description; + this.isDone = false; + } + + /** + * Sets task as done. + * + * @param isDone Status of task. + */ + public void taskDone(boolean isDone) { + this.isDone = isDone; + } + + /** + * Gets status icon of task. + * + * @return Status icon of task. + */ + public String getStatusIcon() { + return (isDone ? "[X]" : "[ ]"); + } + + /** + * Gets status of task. + * + * @return Status of task. + */ + public String getStatus() { + return (isDone ? "1" : "0"); + } + + /** + * Gets icon of task. + * + * @return Icon of task. + */ + public String getIcon() { + return ""; + } + + /** + * Gets Timing of task. + * + * @return timing of task. + */ + public String getTiming() { + return ""; + } + + /** + * Gets description of task. + * + * @return Description of task. + */ + public String getDescription() { + return description; + } + + /** + * Gets time of task + * + * @return Time of task. + */ + public String getTime() { + return ""; + } + + /** + * Returns a string representing the task. + * + * @return String representing task. + */ + public String toString() { + return getStatusIcon() + " " + this.description ; + } + +} diff --git a/src/main/java/duke/task/TaskManager.java b/src/main/java/duke/task/TaskManager.java new file mode 100644 index 000000000..7611b2764 --- /dev/null +++ b/src/main/java/duke/task/TaskManager.java @@ -0,0 +1,289 @@ +package duke.task; + +import duke.DukeException; + +import java.util.ArrayList; +import java.util.stream.Collectors; + +public class TaskManager { + public static ArrayList taskList; + + private static final String TO_DO = "todo"; + private static final String DEADLINE = "deadline"; + private static final String EVENT = "event"; + private static final String ADDED_TASK = " Got it. I've added this task:\n "; + private static final String ENTER_DATE = " ☹ OOPS!!! Please enter a date"; + private static final String OUT_OF_BOUNDS = "Error! Index out of bounds"; + private static final String EMPTY_LIST = " ☹ OOPS!!! List is empty"; + private static final String SHOW_TASKS = " Here are the tasks in your list:"; + private static final String INVALID_COMMAND = " Invalid command, please try again"; + private static final String BY_SEPARATOR = "/by"; + private static final String AT_SEPARATOR = "/at"; + private static final int TODO_STRING_LENGTH = 5; + private static final int DEADLINE_STRING_LENGTH = 9; + private static final int EVENT_STRING_LENGTH = 6; + private static final int SEPARATOR_STRING_LENGTH = 3; + private static final int MINIMUM_COMMAND_LENGTH = 2; + + public TaskManager() { + this.taskList = new ArrayList<>(); + } + + /** + * Adds task to taskList based on their task Type. + * + * @param input Command input. + * @throws DukeException If there is no input after command. + */ + public static void add(String input) throws DukeException { + String[] command = input.split(" "); + if (command.length < MINIMUM_COMMAND_LENGTH) { + throw new DukeException(); + } + String taskType = getCommand(input); + String description = getDescription(input); + String date; + switch (taskType) { + case TO_DO: + addToDo(description); + break; + case DEADLINE: + date = getDate(input); + addDeadline(description, date); + break; + case EVENT: + date = getDate(input); + addEvent(description, date); + break; + default: + System.out.println(INVALID_COMMAND); + return; + } + printSize(); + } + + /** + * Adds ToDo to taskList given description. + * + * @param description Description of ToDo. + */ + public static void addToDo(String description) { + taskList.add(new ToDo(description)); + System.out.println(ADDED_TASK + new ToDo(description)); + } + + /** + * Loads ToDo from file to taskList without printing. + * + * @param description Description of ToDo. + * @param isDone Previous status of ToDo from file. + */ + public static void loadToDoFromFile(String description, boolean isDone) { + taskList.add(new ToDo(description, isDone)); + } + + /** + * Adds Deadline to taskList given description. + * + * @param description Description of deadline. + * @param time Time of deadline. + */ + public static void addDeadline(String description, String time) { + taskList.add(new Deadline(description, time)); + System.out.println(ADDED_TASK + new Deadline(description, time)); + } + + /** + * Loads Deadline from file to taskList without printing. + * + * @param description Description of Deadline. + * @param time Time of Deadline. + * @param isDone Previous status of Deadline from file. + */ + public static void loadDeadlineFromFile(String description, String time, boolean isDone) { + taskList.add(new Deadline(description, time, isDone)); + } + + /** + * Adds Event to taskList given description. + * + * @param description Description of event. + * @param time Time of event. + */ + public static void addEvent(String description, String time) { + taskList.add(new Event(description, time)); + System.out.println(ADDED_TASK + new Event(description, time)); + } + + /** + * Loads Event from file to taskList without printing. + * + * @param description Description of Event. + * @param time Time of Event. + * @param isDone Previous status of Event from file. + */ + public static void loadEventFromFile(String description, String time, boolean isDone) { + taskList.add(new Event(description, time, isDone)); + } + + /** + * Sets task to done. + * + * @param input Array of command for the task. + * @throws NumberFormatException If input is not in numeric type. + */ + public static void setDone(String[] input) throws NumberFormatException{ + try { + Integer.parseInt(input[1]); + } catch (NumberFormatException e) { + throw new NumberFormatException(); + } + taskList.get(Integer.parseInt(input[1]) - 1).taskDone(true); + } + + /** + * Gets description of given task. + * + * @param input Task where description is needed. + * @return Description of task. + */ + public static String getDescription(String input) { + String description; + int separator; + if (getCommand(input).equals(TO_DO)) { + description = input.substring(TODO_STRING_LENGTH); + } else if (getCommand(input).equals(DEADLINE)) { + separator = input.indexOf(BY_SEPARATOR); + description = input.substring(DEADLINE_STRING_LENGTH, separator - 1); + } else if (getCommand(input).equals(EVENT)) { + separator = input.indexOf(AT_SEPARATOR); + description = input.substring(EVENT_STRING_LENGTH, separator - 1); + } else { + description = null; + } + return description; + } + + /** + * Returns type of Task given command. + * + * @param input Input used to obtain task type. + * @return Type of Task. + */ + public static String getCommand(String input) { + String[] task = input.split(" "); + String taskType = task[0]; + + return taskType; + } + + /** + * Prints number of tasks in list + */ + public static void printSize() { + if (getSize() == 0) { + System.out.println(" Now you have 0 task in the list."); + } else if (getSize() == 1) { + System.out.println(" Now you have 1 task in the list."); + } else { + System.out.println(" Now you have " + getSize() + " tasks in the list."); + } + } + + /** + * Returns name of task given task number + * + * @param index index of task in taskList ArrayList + * @return Name of Task + */ + public static String getName(int index) { + return taskList.get(index - 1).toString(); + } + + /** + * Returns size of list. + * @return Size of list + */ + public static int getSize() { + return taskList.size(); + } + + /** + * Lists out all the tasks in taskList + */ + public static void list() { + try { + if (taskList.size() == 0) { + System.out.println(EMPTY_LIST); + return; + } + System.out.println(SHOW_TASKS); + for (int i = 0; i < taskList.size(); i++) { + Task t = taskList.get(i); + System.out.println(" " + (i + 1) + "." + t); + } + } catch (IndexOutOfBoundsException i) { + System.out.println(OUT_OF_BOUNDS); + } + + } + + /** + * Returns date of event or deadline. + * + * @param description command entered. + * @return Date of event or deadline. + */ + public static String getDate(String description) { + String date; + String taskType = getCommand(description); + int indexOfSeparator; + switch (taskType) { + case DEADLINE: + indexOfSeparator = description.indexOf(BY_SEPARATOR); + date = description.substring(indexOfSeparator + SEPARATOR_STRING_LENGTH + 1); + if (date.isEmpty()) { + System.out.println(ENTER_DATE); + } + break; + case EVENT: + indexOfSeparator = description.indexOf(AT_SEPARATOR); + date = description.substring(indexOfSeparator + SEPARATOR_STRING_LENGTH + 1); + if (date.isEmpty()) { + System.out.println(ENTER_DATE); + } + break; + default: + date = null; + break; + } + return date; + } + + /** + * Deletes task given task index + * @param input Input with the index of task to be deleted + */ + public static void deleteTask(String[] input) { + int taskToDelete = Integer.parseInt(input[1]); + Task thisTask = taskList.get(taskToDelete - 1); + System.out.println(" " + thisTask); + taskList.remove(taskToDelete - 1); + printSize(); + } + + public static ArrayList filterTasksByString(ArrayList tasks, String filterString) { + ArrayList filteredList = (ArrayList) tasks.stream() + .filter((t) -> t.getDescription().contains(filterString)) + .collect(Collectors.toList()); + return filteredList; + } + + public static void find(String input) { + ArrayList filteredList = TaskManager.filterTasksByString(taskList, input); + for (int i = 0; i < filteredList.size(); i++) { + Task t = filteredList.get(i); + System.out.println(" " + (i + 1) + "." + t); + } + } +} diff --git a/src/main/java/duke/task/ToDo.java b/src/main/java/duke/task/ToDo.java new file mode 100644 index 000000000..0740eb67a --- /dev/null +++ b/src/main/java/duke/task/ToDo.java @@ -0,0 +1,42 @@ +package duke.task; + +public class ToDo extends Task { + /** + * Constructs a ToDo task given description. + * + * @param description Description of task. + */ + public ToDo(String description) { + super(description); + } + + /** + * Constructs a Todo task given description and isDone status. + * + * @param description Description of task. + * @param isDone Status of task. + */ + public ToDo(String description, boolean isDone) { + this(description); + super.taskDone(isDone); + } + + /** + * Returns icon of Todo. + * + * @return Icon of Todo + */ + public String getIcon() { + return "T"; + } + + /** + * Returns a string representing the ToDo. + * + * @return String representing ToDo. + */ + @Override + public String toString() { + return "[" + getIcon() + "]"+ super.toString(); + } +} diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 000000000..d749a8d57 --- /dev/null +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: duke.command.Duke +