diff --git a/docs/README.md b/docs/README.md index 8077118eb..a119a1c07 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,29 +1,198 @@ -# User Guide +# YOJ User Guide -## Features -### Feature-ABC +## Overview +YOJ is a CLI-based application that allows users to track their tasks. Users can +add and delete tasks from a list, mark them as Done or undone and view all current tasks. This user guide aims to +help users get familiarized with the different commands available in the application. -Description of the feature. -### Feature-XYZ +## Quick Start +1. Download Java11. +2. Download the latest JAR file from [here](https://github.com/liuzehui03/ip/releases/tag/A-Release). +3. Move the JAR file into an empty folder. +4. In the command terminal, use the `cd` command to switch to the + folder with the JAR file. +5. Enter `java -jar ip.jar` in the command terminal to run this application. +6. Refer to the features below for details of the various commands and how to use YOJ. -Description of the feature. -## Usage +## Features -### `Keyword` - Describe action -Describe the action and its outcome. +### Viewing all tasks: `list` -Example of usage: +Shows a list of all the current tasks, along with their +descriptions and status. -`keyword (optional arguments)` -Expected outcome: +Format: `list` -Description of the outcome. +Example of usage: ``` -expected output +list ``` + +Expected output: +``` +AGENDA ✉ +♡ All the best!! 💕 +_____________ +1. [T][ ] add tasks +2. [D][ ] finish user guide (by: monday) +3. [E][X] project meeting (from: Mon 2pm to: 4pm) +``` + +### Adding a ToDo task: `todo` + +Adds a ToDo task to the task list. + +Format: `todo [description]` + +Example of usage: + +``` +todo exercise +``` + +Expected output: +``` +okii task added : +[T][ ] exercise +Now you have 1 tasks in the list +``` + +### Adding a Deadline task: `deadline` + +Adds a Deadline task to the task list. + +Format: `deadline [description] /by [deadline]` + +Example of usage: + +``` +deadline return file /by monday +``` + +Expected output: +``` +okii task added : +[D][ ] return file (by: monday) +Now you have 2 tasks in the list. +``` + +### Adding an Event task: `event` + +Adds an Event task to the task list. + +Format: `event [description] /from [eventStart] /to [eventEnd]` + +Example of usage: + +``` +event project meeting /from Mon 2pm /to 4pm +``` + +Expected output: +``` +okii task added : +[E][ ] project meeting (from: Mon 2pm to: 4pm) +Now you have 3 tasks in the list. +``` + +### Marking a task as done: `mark` + +Changes the status of the selected task to Done. + +Format: `mark [index]` + +Example of usage: + +``` +mark 1 +``` + +Expected output: +``` +okiee! amazing!! I've marked this task as done: +[T][X] exercise +``` + +### Marking a task as undone: `unmark` + +Changes the status of the selected task to Undone. + +Format: `unmark [index]` + +Example of usage: + +``` +unmark 1 +``` + +Expected output: +``` +alright I've marked this task as not done yet, do rmb to do it soon: +[T][ ] exercise +``` + + +### Removing a task: `delete` + +Removes a specific task from the task list. + +Format: `delete [index]` + +Example of usage: + +``` +delete 1 +``` +Expected output: +``` +okiee i've deleted the task +[T][ ] exercise +Now you have 2 tasks in the list. +``` + +### Finding a task: `find` + +Returns all tasks in the task list that contains the keyword. + +Format: `find [keyword]` + +Example of usage: + +``` +find assignment +``` + +Expected output: +``` +🔍 here are the tasks found with the keyword! +1. [T][ ] assignment 3 +2. [T][ ] review assignment 2 +``` + +### Exiting the program: `bye` + +Exits the application and saves all tasks in a file. + +Format: `bye` + +Example of usage: + +``` +bye +``` + + +Expected output: +``` +bye bye!! hope to see u soon :) 😊 +``` +Make sure to say bye to ensure your data is saved properly, otherwise YOJ might not remember the tasks + +### Data Management +Data would be saved locally on your device upon usage of `bye` diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF new file mode 100644 index 000000000..24d523091 --- /dev/null +++ b/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: Yoj.Yoj + diff --git a/src/main/data/Yojdata.txt b/src/main/data/Yojdata.txt new file mode 100644 index 000000000..8d6e83497 --- /dev/null +++ b/src/main/data/Yojdata.txt @@ -0,0 +1,2 @@ +[T] | 0 | haha +[D] | 0 | bfwgr 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/Yoj/Yoj.java b/src/main/java/Yoj/Yoj.java new file mode 100644 index 000000000..d3cfa96ad --- /dev/null +++ b/src/main/java/Yoj/Yoj.java @@ -0,0 +1,45 @@ +package Yoj; + +import Yoj.exception.InvalidCommandException; +import Yoj.exception.YojException; +import Yoj.parser.Parser; +import Yoj.storage.Storage; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Scanner; +import Yoj.taskList.List; +import Yoj.ui.*; + + +public class Yoj { + /** + * main method is the entry point for Yoj which handles user input and commands processing for the task management system. + * + * @param args Command-line arguments passed to the application. + * @throws YojException Custom exception for application-specific errors. + * @throws InvalidCommandException Custom exception for invalid commands entered by the user. + * @throws FileNotFoundException Exception thrown when the file with saved tasks is not found. + * + */ + public static void main(String[] args) throws YojException, InvalidCommandException, FileNotFoundException { + Ui.printHello(); + // get user input + Scanner in = new Scanner(System.in); + List.tasks = Storage.loadTasks(); + String userInput; + do { + userInput = in.nextLine(); + try { + Parser.manageUserInput(userInput); + } catch (YojException e){ + System.out.println(e.getMessage()); + } catch (InvalidCommandException e) { + System.out.println(e.getMessage()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } while (!userInput.equals("bye")); + in.close(); + + } +} diff --git a/src/main/java/Yoj/exception/InvalidCommandException.java b/src/main/java/Yoj/exception/InvalidCommandException.java new file mode 100644 index 000000000..ac28f5a1c --- /dev/null +++ b/src/main/java/Yoj/exception/InvalidCommandException.java @@ -0,0 +1,6 @@ +package Yoj.exception; +public class InvalidCommandException extends Exception{ + public InvalidCommandException(String message){ + super(message); + } +} diff --git a/src/main/java/Yoj/exception/YojException.java b/src/main/java/Yoj/exception/YojException.java new file mode 100644 index 000000000..1b17cf1ff --- /dev/null +++ b/src/main/java/Yoj/exception/YojException.java @@ -0,0 +1,6 @@ +package Yoj.exception; +public class YojException extends Exception { + public YojException(String message) { + super(message); + } + } diff --git a/src/main/java/Yoj/parser/Parser.java b/src/main/java/Yoj/parser/Parser.java new file mode 100644 index 000000000..68430a08a --- /dev/null +++ b/src/main/java/Yoj/parser/Parser.java @@ -0,0 +1,48 @@ +package Yoj.parser; + +import Yoj.taskList.List; +import Yoj.exception.InvalidCommandException; +import Yoj.exception.YojException; +import Yoj.storage.Storage; +import Yoj.ui.Ui; +import java.io.IOException; +import static Yoj.taskList.List.tasks; + +/** + * This class is responsible for parsing the user input and managing the corresponding actions. + */ +public class Parser { + /** + * Parses the user input and invokes the appropriate action based on the command. + * + * @param userInput The full line of input entered by the user. + * @throws YojException If there's a problem specific to Yoj's functionality. + * @throws InvalidCommandException If the entered command is not recognized. + * @throws IOException If there is an input/output error during task handling. + */ + public static void manageUserInput(String userInput) throws YojException, InvalidCommandException, IOException { + if (userInput.equals("list")) { + Ui.printList(); + } else if(userInput.matches("mark \\d+")) { + String[] taskIndex = userInput.split(" "); + int index = Integer.parseInt(taskIndex[1] ); + tasks.get(index - 1).markDone(); + Ui.markDoneMessage(index); + } else if(userInput.matches("unmark \\d+")) { + String[] taskIndex = userInput.split(" "); + int index = Integer.parseInt(taskIndex[1]); + tasks.get(index - 1).markUndone(); + Ui.markUndoneMessage(index); + } else if(userInput.startsWith("todo") || userInput.startsWith("deadline") || userInput.startsWith("event")) { + List.addTask(userInput); + } else if(userInput.startsWith("delete")) { + List.deleteTask(userInput); + } else if(userInput.startsWith("find")) { + String description = userInput.substring("find ".length()).trim(); + List.findTask(description); + } else if(userInput.equals("bye")){ + Ui.byeMessage(); + Storage.save(tasks); + } else throw new InvalidCommandException("unfortunately im not sure what u mean... :<"); + } +} diff --git a/src/main/java/Yoj/storage/Storage.java b/src/main/java/Yoj/storage/Storage.java new file mode 100644 index 000000000..9f5174ac6 --- /dev/null +++ b/src/main/java/Yoj/storage/Storage.java @@ -0,0 +1,122 @@ +package Yoj.storage; + +import Yoj.tasks.*; +import Yoj.ui.Ui; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.FileSystems; +import java.util.ArrayList; +import java.util.Scanner; + +public class Storage { + private static final String FILE_PATH = makeFilePath(); + + private static String makeFilePath() { + String userHome = System.getProperty("user.home"); + String separator = FileSystems.getDefault().getSeparator(); // Construct the directory path separately + String directoryPath = userHome + separator + "Desktop" + separator + "Yoj"; + File YojDirectory = new File(directoryPath); + // Ensure the directory exists + if (!YojDirectory.exists()) { + boolean wasSuccessful = YojDirectory.mkdirs(); // Create the directory if it doesn't exist + if (wasSuccessful) { + Ui.printCreateFile(); + } else { + Ui.printFileCreationFailed(); + } + } + String filePath = directoryPath + separator + "Yojdata.txt"; + return filePath; + } + /** + * Loads tasks from the storage file. + * + * @return An ArrayList of Task objects loaded from the file. + */ + public static ArrayList loadTasks() { + ArrayList loadedTasks = new ArrayList<>(); + try { + File file = new File(FILE_PATH); + Scanner scanner = new Scanner(file); + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + String[] parts = line.split(" \\| "); + // Expected format: Type | Completed | Description + if (parts.length < 3) { + break; + } + String type = parts[0].trim(); + boolean isCompleted = parts[1].trim().equals("1"); + String description = parts[2].trim(); + Task task = null; + switch (type) { + case "[T]": + task = new ToDo(description); + break; + case "[D]": + String[] deadlineParts = description.split(" by "); + if (deadlineParts.length == 2) { + task = new Deadline(deadlineParts[0], deadlineParts[1]); + } + break; + case "[E]": + String[] eventDetails = parts[2].trim().split(" from "); + if (eventDetails.length < 2) { + return null; + } + String eventDescription = eventDetails[0].trim(); + String[] timeDetails = eventDetails[1].trim().split(" to "); + if (timeDetails.length < 2) { + return null; + } + String startTime = timeDetails[0].trim(); + String endTime = timeDetails[1].trim(); + task = new Event(eventDescription, startTime, endTime); + break; + } + if (task != null) { + if (isCompleted) { + task.markDone(); + } + loadedTasks.add(task); + } + } + scanner.close(); + } catch (FileNotFoundException e) { + Ui.printFilenotFound(); + } + return loadedTasks; + } + + /** + * Saves the current tasks to the storage file. + * + * @param tasks The ArrayList of Task objects to be saved. + * @throws IOException If there is an error writing to the file. + */ + public static void save(ArrayList tasks) throws IOException { + FileWriter fw = new FileWriter(FILE_PATH); // create a FileWriter in append mode + try { + for (Task task : tasks) { // loop through the ArrayList + String textToWrite = task.taskType() + " | " + task.isCompleted(); + if (task instanceof Deadline) { + Deadline deadlineTask = (Deadline) task; + textToWrite += " | " + deadlineTask.getDescription() + " by " + deadlineTask.getBy(); + } else if (task instanceof Event) { + Event eventTask = (Event) task; + textToWrite += " | " + eventTask.getDescription() + " from " + eventTask.getStart() + " to " + eventTask.getEnd(); + } else { + textToWrite += " | " + task.getDescription(); + } + textToWrite += System.lineSeparator(); + fw.write(textToWrite); // write the task to the file + } + } finally { + fw.close(); + } + } + +} + diff --git a/src/main/java/Yoj/taskList/List.java b/src/main/java/Yoj/taskList/List.java new file mode 100644 index 000000000..c3cb9d62a --- /dev/null +++ b/src/main/java/Yoj/taskList/List.java @@ -0,0 +1,126 @@ +package Yoj.taskList; + +import Yoj.exception.YojException; +import Yoj.tasks.Deadline; +import Yoj.tasks.Event; +import Yoj.tasks.ToDo; +import Yoj.tasks.Task; +import Yoj.ui.*; +import java.io.IOException; +import java.util.ArrayList; + +public class List { + public static ArrayList tasks = new ArrayList<>(); + /** + * Adds a new task to the list based on user input. + * + * @param userInput input from the user specifying the task to add. + * @throws YojException If the task cannot be added due to invalid format or other reasons. + * @throws IOException If there is an error during input/output operation. + */ + public static void addTask(String userInput) throws YojException, IOException { + if (userInput.startsWith("todo")) { + manageToDo(userInput); + } else if (userInput.startsWith("deadline")) { + manageDeadline(userInput); + } else if (userInput.startsWith("event")) { + manageEvent(userInput); + } + Ui.printShortLine(); + Ui.addTaskMessage(); + Ui.printLine(); + } + /** + * Deletes a task from the list based on the task index provided by the user. + * + * @param userInput input from the user specifying the task number to delete. + * @throws YojException If the task number is not specified or invalid. + */ + public static void deleteTask(String userInput) throws YojException { + String taskNum = userInput.substring("delete".length()).trim(); + if (taskNum.isEmpty()) { + throw new YojException("do specify the task number of what u want to delete..."); + } + try { + int num = Integer.parseInt(taskNum); + if (tasks.size() == 0) { + Ui.noDeleteMessage(); + } else if (num > 0 && num <= tasks.size()) { + Task deletedTask = tasks.remove(num - 1); + Ui.taskDeletedMessage(deletedTask); + } else { + Ui.wrongDeleteMessage(); + } + } catch (NumberFormatException e) { + Ui.wrongDeleteMessage(); + } + + } + /** + * Handles adding a ToDo task. + * + * @param userInput input from the user containing the task description. + * @throws YojException If the description is empty. + * @throws IOException If there is an error during input/output operation. + */ + public static void manageToDo(String userInput) throws YojException, IOException { + String description = userInput.substring("todo".length()).trim(); + if (description.isEmpty()) { + throw new YojException("The description of todo cannot be empty..."); + } else { + tasks.add(new ToDo(userInput.substring(5))); + } + } + /** + * Handles adding a Deadline task. + * + * @param userInput input from the user containing the task description and deadline. + * @throws YojException If the description is empty or improperly formatted. + * @throws IOException If there is an error during input/output operation. + */ + public static void manageDeadline(String userInput) throws YojException, IOException { + String description = userInput.substring("deadline".length()).trim(); + if (description.isEmpty()) { + throw new YojException("The description of deadline cannot be empty..."); + } else { + String[] parts = userInput.substring(9).split(" /by "); + tasks.add(new Deadline(parts[0].trim(), parts[1].trim())); + } + } + /** + * Handles adding an Event task. + * + * @param userInput input from the user containing the task description and event times. + * @throws YojException If the description is empty or improperly formatted. + * @throws IOException If there is an error during input/output operation. + */ + public static void manageEvent(String userInput) throws YojException, IOException { + String description = userInput.substring("event".length()).trim(); + if (description.isEmpty()) { + throw new YojException("The description of event cannot be empty..."); + } else { + String[] parts = userInput.substring(6).split(" /from "); + String[] times = parts[1].split(" /to "); + tasks.add(new Event(parts[0].trim(), times[0].trim(), times[1].trim())); + } + } + /** + * Searches for tasks that contain the given input by users. + * + * @param userInput The specific keyword to find. + */ + public static void findTask(String userInput) { + ArrayList tasksFound = new ArrayList<>(); + for (Task task : tasks) { + if (task.getDescription().contains(userInput)) { + tasksFound.add(task); + } + } + if (tasksFound.isEmpty()){ + Ui.printNoTaskFound(); + } else { + Ui.printTaskFound(tasksFound); + } + } + +} diff --git a/src/main/java/Yoj/tasks/Deadline.java b/src/main/java/Yoj/tasks/Deadline.java new file mode 100644 index 000000000..51e4289f3 --- /dev/null +++ b/src/main/java/Yoj/tasks/Deadline.java @@ -0,0 +1,36 @@ +package Yoj.tasks; +public class Deadline extends Task { + protected String by; + /** + * Returns the type identifier for the task. + * + * @return A string representing the type of the task, which is "[D]" for Deadline. + */ + public String taskType() { + return "[D]"; + } + /** + * Constructor for a Deadline task. + * + * @param description The description of the task. + * @param by The time by which the task is due. + */ + public Deadline(String description, String by) { + super(description); + this.by = by; + } + + /** + * Provides a string representation of the Deadline task including its type, status, description, and deadline. + * + * @return A string representing the Deadline task, formatted with its deadline time. + */ + @Override + public String toString() { + return taskType() + super.toString() + " (by: " + by + ")"; + } + + public String getBy() { + return by; + } +} \ No newline at end of file diff --git a/src/main/java/Yoj/tasks/Event.java b/src/main/java/Yoj/tasks/Event.java new file mode 100644 index 000000000..9a369c642 --- /dev/null +++ b/src/main/java/Yoj/tasks/Event.java @@ -0,0 +1,42 @@ +package Yoj.tasks; +public class Event extends Task { + protected String start; + protected String end; + /** + * Constructor for Event class with the given description(userInput), start time, and end time. + * + * @param description A string representing the event's description. + * @param start A string representing the start time of the event. + * @param end A string representing the end time of the event. + */ + public Event(String description, String start, String end) { + super(description); + this.start = start; + this.end = end; + } + /** + * Returns the type of the task, in this case "[E]" to represent an event + * + * @return A string indicating the type of the task. + */ + public String taskType() { + return "[E]"; + } + /** + * Provides a string representation of the event task, including its type and description. + * It overrides the `toString` method in the superclass (Task). + * + * @return A string that represents the event task. + */ + @Override + public String toString() { + return taskType() + super.toString() + " (from: " + start + " to: " + end + ")"; + } + + public String getStart() { + return start; + } + public String getEnd() { + return end; + } +} \ No newline at end of file diff --git a/src/main/java/Yoj/tasks/Task.java b/src/main/java/Yoj/tasks/Task.java new file mode 100644 index 000000000..dffc19278 --- /dev/null +++ b/src/main/java/Yoj/tasks/Task.java @@ -0,0 +1,68 @@ +package Yoj.tasks; +public class Task { + protected String description; + protected boolean isDone; + /** + * Constructs a new Task with the given description. By default, the task is not completed. + * + * @param description The description of the task, which is the user input + */ + public Task(String description) { + this.description = description; + this.isDone = false; + } + /** + * Retrieves the description of the task. + * + * @return The description of the task. + */ + public String getDescription() { + return description; + } + /** + * Marks the task as done by setting the completion status to true. + */ + public void markDone() { + this.isDone = true; + } + /** + * Marks the task as not done by setting the completion status to false. + */ + public void markUndone() { + this.isDone = false; + } + /** + * Returns the completion status of the task as a string, "1" if isDone is true, "0" otherwise. + * + * @return A string representing the completion status of the task. + */ + public String isCompleted() { + return (isDone ? "1" : "0"); + } + /** + * Gets a status icon representing the task's completion status. "X" if completed, " " (space) otherwise. + * + * @return A string representing the visual status icon of the task. + */ + public String getStatusIcon() { + return (isDone ? "X" : " "); // mark done task with X + } + /** + * Returns the type of the task. This method should be overridden in subclasses to provide the specific type. + * + * @return A string representing the type of the task. + */ + public String taskType() { + return "[ ]"; + } + /** + * Returns a string representation of the task, including its status icon and description. + * + * @return A string representation of the task. + */ + @Override + public String toString() { + return "[" + this.getStatusIcon() + "] " + this.getDescription(); + } + +} \ No newline at end of file diff --git a/src/main/java/Yoj/tasks/ToDo.java b/src/main/java/Yoj/tasks/ToDo.java new file mode 100644 index 000000000..8449b4bae --- /dev/null +++ b/src/main/java/Yoj/tasks/ToDo.java @@ -0,0 +1,30 @@ +package Yoj.tasks; +public class ToDo extends Task { + /** + * Constructor for the ToDo class. + * It calls the parent class's constructor to set the task's description. + * @param description The text description of what the to-do task is. + * + */ + public ToDo (String description){ + super(description); + } + /** + * Returns the type of the task, in this case "[T]" to represent a todo task. + * + * @return A string indicating the type of the task. + */ + public String taskType() { + return "[T]"; + } + /** + * Provides a string representation of the to-do task, including its type and description. + * It overrides the `toString` method in the superclass (Task). + * + * @return A string that represents the todo task. + */ + @Override + public String toString(){ + return taskType() + super.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/Yoj/ui/Ui.java b/src/main/java/Yoj/ui/Ui.java new file mode 100644 index 000000000..f0d857ac5 --- /dev/null +++ b/src/main/java/Yoj/ui/Ui.java @@ -0,0 +1,140 @@ +package Yoj.ui; + +import Yoj.taskList.*; +import Yoj.tasks.Task; +import java.util.ArrayList; + +public class Ui { + /** + * Prints a long line for formatting. + */ + public static void printLine() { + System.out.println("________________________________________"); + } + /** + * Prints a short line for formatting. + */ + public static void printShortLine() { + System.out.println("_____________"); + } + /** + * Prints an introduction, logo and user prompt. + */ + public static void printHello() { + String logo = + "__ __ ___ _____ \n" + + "\\ \\ / / / _ \\ | ___ |\n" + + " \\ Y / | | | | | | \n" + + " \\ / | | | | | | \n" + + " | | | |_| | ___| | \n" + + " |_| \\___/ |____/ \n"; + printLine(); + System.out.println("Hello from\n" + logo); + System.out.println("Hello! I'm YOJ \uD83D\uDE3A"); + System.out.println("What can I do for you?"); + printShortLine(); + } + /** + * Prints a message indicating that the task has been successfully added to the task list. + */ + public static void addTaskMessage() { + System.out.println("okii task added :"); + System.out.println(List.tasks.get(List.tasks.size() - 1)); + System.out.println("Now you have " + List.tasks.size() + " tasks in the list."); + } + /** + * Prints a message after task is marked as done. + * @param index The index of the specific task in the arraylist. + */ + public static void markDoneMessage(int index) { + System.out.println("okiee! amazing!! I've marked this task as done: "); + System.out.println(List.tasks.get(index-1).taskType() + "[X] " + List.tasks.get(index - 1).getDescription()); + printLine(); + } + /** + * Prints a message after task is marked as undone. + * @param index The index of the specific task in the arraylist. + */ + public static void markUndoneMessage(int index) { + System.out.println("alright I've marked this task as not done yet, do rmb to do it soon: "); + System.out.println(List.tasks.get(index-1).taskType() + "[ ] " + List.tasks.get(index - 1).getDescription()); + printLine(); + } + /** + * Prints the list of current tasks. + */ + public static void printList() { + printLine(); + if (List.tasks.size() == 0) { + System.out.println("the list is currently empty..."); + System.out.println("add your tasks below :)"); + } else { + System.out.println("AGENDA ✉"); + System.out.println("♡ All the best!! <3 "); + printShortLine(); + for (int i = 0; i < List.tasks.size(); i++) { + System.out.println(i + 1 + ". " + List.tasks.get(i).toString()); + } + printLine(); + } + } + /** + * Prints message to inform user of tasks deleted. + * @param deletedTask The specific description of the deleted task + */ + public static void taskDeletedMessage(Task deletedTask) { + printShortLine(); + if (List.tasks.size() == 0) { + System.out.println("okiee i've deleted the task"); + System.out.println(deletedTask); + System.out.println("there's no more tasks in the list.. please add new tasks below :)"); + } else { + System.out.println("okiee i've deleted the task"); + System.out.println(deletedTask); + System.out.println("Now you have " + List.tasks.size() + " tasks in the list."); + } + printLine(); + } + public static void noDeleteMessage() { + System.out.println("there's no more tasks to delete..."); + } + public static void wrongDeleteMessage() { + System.out.println("pls make my life easier.. check that you have the CORRECT task number to be deleted \uD83D\uDC80"); + } + /** + * Prints out tasks containing specific keyword based on user input. + * @param tasksFound The list of tasks that contain the keyword. + */ + public static void printTaskFound(ArrayList tasksFound) { + printShortLine(); + System.out.println("\uD83D\uDD0D here are the tasks found with the keyword!"); + for (int i = 0; i < tasksFound.size(); i++) { + System.out.println(i + 1 + ". " + tasksFound.get(i)); + } + printLine(); + } + /** + * Prints message to inform user that there are no tasks with similar keyword. + */ + public static void printNoTaskFound() { + System.out.println("there are no such tasks found... "); + } + /** + * Prints exit message. + */ + public static void byeMessage() { + System.out.println("bye bye!! hope to see u soon :) \uD83D\uDE0A"); + } + /** + * Prints message to inform user that there is no existing File and file creation is in process. + */ + public static void printFilenotFound() { + System.out.println("fixing up file in process..... pls be patient :)"); + } + public static void printCreateFile() { + System.out.println("YAYY! 'Yoj' directory was successfully created on the Desktop hehe "); + } + public static void printFileCreationFailed() { + System.out.println("did not manage to create the 'Yoj' directory on the Desktop:(("); + } +} diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 657e74f6e..5479f03e8 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,7 +1,10 @@ Hello from - ____ _ -| _ \ _ _| | _____ -| | | | | | | |/ / _ \ -| |_| | |_| | < __/ -|____/ \__,_|_|\_\___| +__ __ ___ _____ +\ \ / / / _ \ | ___ | + \ Y / | | | | | | + \ / | | | | | | + | | | |_| | ___| | + |_| \___/ |____/ +Hello! I'm YOJ +What can I do for you? \ No newline at end of file diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index e69de29bb..32ce96ff0 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -0,0 +1,3 @@ +list +mark +unmark \ No newline at end of file diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat index 087374464..a77b5c48a 100644 --- a/text-ui-test/runtest.bat +++ b/text-ui-test/runtest.bat @@ -4,7 +4,7 @@ REM create bin directory if it doesn't exist if not exist ..\bin mkdir ..\bin REM delete output from previous run -if exist ACTUAL.TXT del ACTUAL.TXT +del ACTUAL.TXT REM compile the code into the bin folder javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java @@ -15,7 +15,7 @@ IF ERRORLEVEL 1 ( REM no error here, errorlevel == 0 REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT -java -classpath ..\bin Duke < input.txt > ACTUAL.TXT +java -classpath ..\bin Yoj < input.txt > ACTUAL.TXT REM compare the output to the expected output FC ACTUAL.TXT EXPECTED.TXT