diff --git a/src/main/java/AddDeadlineCommand.class b/src/main/java/AddDeadlineCommand.class index 2f3dc3ddf..692e86ed1 100644 Binary files a/src/main/java/AddDeadlineCommand.class and b/src/main/java/AddDeadlineCommand.class differ diff --git a/src/main/java/AddDeadlineCommand.java b/src/main/java/AddDeadlineCommand.java index 49a545d51..cb24f3588 100644 --- a/src/main/java/AddDeadlineCommand.java +++ b/src/main/java/AddDeadlineCommand.java @@ -1,6 +1,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; + /** * Command to add a deadline task. */ @@ -8,6 +9,7 @@ public class AddDeadlineCommand extends Command { private String description; private String by; private static final DateTimeFormatter INPUT_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm"); + /** * Constructs an AddDeadlineCommand with the specified input. * @@ -18,11 +20,12 @@ public AddDeadlineCommand(String input) { this.description = parts[0].trim().substring(9).trim(); this.by = parts[1].trim(); } + /** * Executes the command to add the deadline task to the task list. * - * @param tasks The task list to which the task will be added. - * @param ui The user interface for displaying messages to the user. + * @param tasks The task list to which the task will be added. + * @param ui The user interface for displaying messages to the user. * @param storage The storage for saving tasks to a file. */ @Override diff --git a/src/main/java/AddEventCommand.class b/src/main/java/AddEventCommand.class index 5f5e86d7c..6de7d0b8e 100644 Binary files a/src/main/java/AddEventCommand.class and b/src/main/java/AddEventCommand.class differ diff --git a/src/main/java/AddEventCommand.java b/src/main/java/AddEventCommand.java index 40f929fee..55cc60f41 100644 --- a/src/main/java/AddEventCommand.java +++ b/src/main/java/AddEventCommand.java @@ -1,14 +1,34 @@ +/** + * Represents a command to add a new event to the task list. + * This command creates a new Event task with a description, start time, and end time. + */ public class AddEventCommand extends Command { private String description; private String from; private String to; + /** + * Constructs a new AddEventCommand with the specified event details. + * + * @param description The description of the event. + * @param from The start time/date of the event. + * @param to The end time/date of the event. + */ public AddEventCommand(String description, String from, String to) { this.description = description; this.from = from; this.to = to; } + /** + * Executes the command to add a new event to the task list. + * This method creates a new Event, adds it to the task list, updates the UI, + * and saves the updated task list to storage. + * + * @param tasks The TaskList to which the new event will be added. + * @param ui The Ui object used to display output to the user. + * @param storage The Storage object used to save the updated task list. + */ @Override public void execute(TaskList tasks, Ui ui, Storage storage) { Task newTask = new Event(description, from, to); diff --git a/src/main/java/AddTodoCommand.class b/src/main/java/AddTodoCommand.class index 75b669e16..215b4bf56 100644 Binary files a/src/main/java/AddTodoCommand.class and b/src/main/java/AddTodoCommand.class differ diff --git a/src/main/java/AddTodoCommand.java b/src/main/java/AddTodoCommand.java index cfbcbee31..bf922e5db 100644 --- a/src/main/java/AddTodoCommand.java +++ b/src/main/java/AddTodoCommand.java @@ -3,6 +3,7 @@ */ public class AddTodoCommand extends Command { private String description; + /** * Constructs an AddTodoCommand with the specified description. * @@ -11,11 +12,12 @@ public class AddTodoCommand extends Command { public AddTodoCommand(String description) { this.description = description; } + /** * Executes the command to add the todo task to the task list. * - * @param tasks The task list to which the task will be added. - * @param ui The user interface for displaying messages to the user. + * @param tasks The task list to which the task will be added. + * @param ui The user interface for displaying messages to the user. * @param storage The storage for saving tasks to a file. */ @Override diff --git a/src/main/java/Command.class b/src/main/java/Command.class index e120c8d97..3b58bf141 100644 Binary files a/src/main/java/Command.class and b/src/main/java/Command.class differ diff --git a/src/main/java/Command.java b/src/main/java/Command.java index a29013e24..7f959fbf4 100644 --- a/src/main/java/Command.java +++ b/src/main/java/Command.java @@ -1,6 +1,26 @@ +/** + * Represents an abstract command in the task management system. + * This class serves as a base for all concrete command implementations. + */ public abstract class Command { + /** + * Executes the command. + * This method should be implemented by all concrete command classes to define + * their specific behavior. + * + * @param tasks The TaskList on which the command operates. + * @param ui The Ui object used to interact with the user. + * @param storage The Storage object used to save and load tasks. + * @throws PoirotException If an error occurs during command execution. + */ public abstract void execute(TaskList tasks, Ui ui, Storage storage) throws PoirotException; + /** + * Checks if this command should exit the program. + * By default, commands do not exit the program. + * + * @return true if the program should exit after this command, false otherwise. + */ public boolean isExit() { return false; } diff --git a/src/main/java/Deadline.class b/src/main/java/Deadline.class index 830d4fbfd..3169ee89f 100644 Binary files a/src/main/java/Deadline.class and b/src/main/java/Deadline.class differ diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java index 84fe016da..f73f6a1c7 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/Deadline.java @@ -1,21 +1,41 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +/** + * Represents a deadline task in the task management system. + * A deadline task is a task that needs to be completed by a specific date and time. + */ public class Deadline extends Task { private LocalDateTime by; private static final DateTimeFormatter INPUT_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm"); private static final DateTimeFormatter OUTPUT_FORMAT = DateTimeFormatter.ofPattern("MMM d yyyy, hh:mm a"); + /** + * Constructs a new Deadline task with the given description and deadline. + * + * @param description The description of the deadline task. + * @param by The deadline date and time in the format "yyyy-MM-dd HHmm". + */ public Deadline(String description, String by) { super(description); this.by = LocalDateTime.parse(by, INPUT_FORMAT); } + /** + * Returns a string representation of the deadline task. + * + * @return A formatted string representing the deadline task, including its status, description, and deadline. + */ @Override public String toString() { return "[D][" + getStatusIcon() + "] " + description + " (by: " + by.format(OUTPUT_FORMAT) + ")"; } + /** + * Returns a string representation of the deadline task for file storage. + * + * @return A formatted string representing the deadline task for saving to a file. + */ @Override public String toFileString() { return "D | " + (isDone ? "1" : "0") + " | " + description + " | " + by.format(INPUT_FORMAT); diff --git a/src/main/java/DeleteCommand.class b/src/main/java/DeleteCommand.class index ea37e3a6a..c040f7cf9 100644 Binary files a/src/main/java/DeleteCommand.class and b/src/main/java/DeleteCommand.class differ diff --git a/src/main/java/DeleteCommand.java b/src/main/java/DeleteCommand.java index 04aef79d9..17c960324 100644 --- a/src/main/java/DeleteCommand.java +++ b/src/main/java/DeleteCommand.java @@ -3,6 +3,7 @@ */ public class DeleteCommand extends Command { private int index; + /** * Constructs a DeleteCommand with the specified index. * @@ -15,8 +16,8 @@ public DeleteCommand(int index) { /** * Executes the command to delete the specified task from the task list. * - * @param tasks The task list from which the task will be deleted. - * @param ui The user interface for displaying messages to the user. + * @param tasks The task list from which the task will be deleted. + * @param ui The user interface for displaying messages to the user. * @param storage The storage for saving tasks to a file. * @throws PoirotException If the index is out of bounds. */ diff --git a/src/main/java/Event.java b/src/main/java/Event.java index 0e049dc38..d5c4cdda8 100644 --- a/src/main/java/Event.java +++ b/src/main/java/Event.java @@ -11,8 +11,8 @@ public class Event extends Task { * Constructs an Event with the specified description, from, and to time. * * @param description The description of the event. - * @param from The starting time of the event in 'yyyy-MM-dd HHmm' format. - * @param to The ending time of the event in 'yyyy-MM-dd HHmm' format. + * @param from The starting time of the event in 'yyyy-MM-dd HHmm' format. + * @param to The ending time of the event in 'yyyy-MM-dd HHmm' format. */ public Event(String description, String from, String to) { super(description); diff --git a/src/main/java/ExitCommand.class b/src/main/java/ExitCommand.class index e2cb55c46..9a437394f 100644 Binary files a/src/main/java/ExitCommand.class and b/src/main/java/ExitCommand.class differ diff --git a/src/main/java/ExitCommand.java b/src/main/java/ExitCommand.java index ed9d0b986..611ff78f4 100644 --- a/src/main/java/ExitCommand.java +++ b/src/main/java/ExitCommand.java @@ -5,14 +5,15 @@ public class ExitCommand extends Command { /** * Executes the command to exit the application. * - * @param tasks The task list (not used). - * @param ui The user interface for displaying messages to the user. + * @param tasks The task list (not used). + * @param ui The user interface for displaying messages to the user. * @param storage The storage for saving tasks to a file (not used). */ @Override public void execute(TaskList tasks, Ui ui, Storage storage) { ui.showExit(); } + /** * Indicates whether this command is an exit command. * diff --git a/src/main/java/ListCommand.java b/src/main/java/ListCommand.java index e6ab13067..e60852602 100644 --- a/src/main/java/ListCommand.java +++ b/src/main/java/ListCommand.java @@ -5,8 +5,8 @@ public class ListCommand extends Command { /** * Executes the command to display the list of tasks. * - * @param tasks The task list to display. - * @param ui The user interface for displaying messages to the user. + * @param tasks The task list to display. + * @param ui The user interface for displaying messages to the user. * @param storage The storage for saving tasks to a file (not used). */ @Override diff --git a/src/main/java/Parser.class b/src/main/java/Parser.class index e2071476a..e80c83dbc 100644 Binary files a/src/main/java/Parser.class and b/src/main/java/Parser.class differ diff --git a/src/main/java/Parser.java b/src/main/java/Parser.java index 860be89c2..6d08d2916 100644 --- a/src/main/java/Parser.java +++ b/src/main/java/Parser.java @@ -1,4 +1,14 @@ +/** + * The Parser class is responsible for parsing user input and creating appropriate Command objects. + */ public class Parser { + /** + * Parses the input string and returns the corresponding Command object. + * + * @param input The user input string to be parsed. + * @return A Command object based on the parsed input. + * @throws PoirotException If the input is invalid or cannot be parsed. + */ public static Command parse(String input) throws PoirotException { String[] list_input = input.split(" "); switch (list_input[0]) { @@ -24,21 +34,33 @@ public static Command parse(String input) throws PoirotException { throw new PoirotException("Unknown command!"); } } - + /** + * Parses the deadline command input and creates an AddDeadlineCommand object. + * + * @param input The deadline command input string. + * @return An AddDeadlineCommand object. + * @throws PoirotException If the deadline format is invalid. + */ private static Command parseDeadlineCommand(String input) throws PoirotException { try { String[] parts = input.split("/by"); if (parts.length < 2) { throw new PoirotException("Invalid deadline format! Use: deadline /by "); } - String description = parts[0].trim().substring(9).trim(); + String description = parts[0].trim(); String by = parts[1].trim(); return new AddDeadlineCommand(description + " /by " + by); } catch (ArrayIndexOutOfBoundsException e) { throw new PoirotException("Invalid format for deadline command."); } } - + /** + * Parses the event command input and creates an AddEventCommand object. + * + * @param input The event command input string. + * @return An AddEventCommand object. + * @throws PoirotException If the event format is invalid. + */ private static Command parseEventCommand(String input) throws PoirotException { try { if (!input.contains("/from") || !input.contains("/to")) { diff --git a/src/main/java/Poirot.class b/src/main/java/Poirot.class index 74fd58a02..da34a1d60 100644 Binary files a/src/main/java/Poirot.class and b/src/main/java/Poirot.class differ diff --git a/src/main/java/Poirot.java b/src/main/java/Poirot.java index 9e0354baa..02fd881e9 100644 --- a/src/main/java/Poirot.java +++ b/src/main/java/Poirot.java @@ -1,9 +1,19 @@ +/** + * The main class for the Poirot task management application. + * This class initializes the application, loads saved tasks, and runs the main command loop. + */ public class Poirot { private Storage storage; private TaskList tasks; private Ui ui; + /** + * Constructs a new Poirot application instance. + * Initializes the UI, storage, and task list, and loads any previously saved tasks. + * + * @param filePath The file path for storing and loading tasks. + */ public Poirot(String filePath) { ui = new Ui(); storage = new Storage(filePath); @@ -17,6 +27,10 @@ public Poirot(String filePath) { } } + /** + * Runs the main command loop of the application. + * Continuously reads user input, executes commands, and displays results until an exit command is given. + */ public void run() { ui.showWelcome(); boolean isExit = false; @@ -32,6 +46,12 @@ public void run() { } } + /** + * The main entry point for the Poirot application. + * Creates a new Poirot instance and starts running it. + * + * @param args Command line arguments (not used). + */ public static void main(String[] args) { new Poirot("./data/duke.txt").run(); } diff --git a/src/main/java/PoirotException.class b/src/main/java/PoirotException.class index 8f16cb644..92234d430 100644 Binary files a/src/main/java/PoirotException.class and b/src/main/java/PoirotException.class differ diff --git a/src/main/java/PoirotException.java b/src/main/java/PoirotException.java index e2a4d4b3c..6817ab4a6 100644 --- a/src/main/java/PoirotException.java +++ b/src/main/java/PoirotException.java @@ -1,5 +1,14 @@ -public class PoirotException extends Exception{ - public PoirotException(String message){ +/** + * Represents a custom exception for the Poirot task management application. + * This exception is used to handle application-specific errors and provide meaningful error messages. + */ +public class PoirotException extends Exception { + /** + * Constructs a new PoirotException with the specified error message. + * + * @param message The detailed error message explaining the reason for the exception. + */ + public PoirotException(String message) { super(message); } } diff --git a/src/main/java/Storage.class b/src/main/java/Storage.class index 7fa1fab4d..15438ee4e 100644 Binary files a/src/main/java/Storage.class and b/src/main/java/Storage.class differ diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index dd59da6f9..f4a177e7f 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -1,10 +1,12 @@ import java.io.*; import java.util.Scanner; + /** * Handles loading and saving tasks to a file. */ public class Storage { private String filePath; + /** * Constructs a Storage object with the specified file path. * @@ -62,6 +64,7 @@ public Task[] loadTasksFromFile() { return tasks; } + /** * Saves the specified tasks to the file. * diff --git a/src/main/java/Task.class b/src/main/java/Task.class index 48e01303a..a60f77cd6 100644 Binary files a/src/main/java/Task.class and b/src/main/java/Task.class differ diff --git a/src/main/java/Task.java b/src/main/java/Task.java index 4cb4d4dde..8f9059125 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -4,6 +4,7 @@ abstract class Task { protected String description; protected boolean isDone; + /** * Constructs a Task with the specified description. * @@ -13,9 +14,11 @@ public Task(String description) { this.description = description; this.isDone = false; } + public String getDescription() { return description; } + /** * Returns the status icon of the task. * @@ -24,6 +27,7 @@ public String getDescription() { public String getStatusIcon() { return (isDone ? "X" : " "); } + /** * Marks the task as done or not done. * @@ -32,7 +36,9 @@ public String getStatusIcon() { public void setDone(boolean isDone) { this.isDone = isDone; } + public abstract String toString(); + /** * Returns a string representation for saving the task to a file. * diff --git a/src/main/java/TaskList.class b/src/main/java/TaskList.class index 9b205c114..2776cf037 100644 Binary files a/src/main/java/TaskList.class and b/src/main/java/TaskList.class differ diff --git a/src/main/java/TaskList.java b/src/main/java/TaskList.java index 2815eae59..aa9abad5b 100644 --- a/src/main/java/TaskList.java +++ b/src/main/java/TaskList.java @@ -1,4 +1,5 @@ import java.util.ArrayList; + /** * Represents a list of tasks. */ @@ -26,6 +27,7 @@ public ArrayList findTasks(String keyword) { } return foundTasks; } + /** * Deletes a task from the task list at the specified index. * @@ -38,6 +40,7 @@ public void delete(int index) { tasks[lastIndex - 1] = null; lastIndex--; } + /** * Returns the list of tasks. * @@ -46,6 +49,7 @@ public void delete(int index) { public Task[] getTasks() { return tasks; } + /** * Returns the number of tasks in the task list. * @@ -54,6 +58,7 @@ public Task[] getTasks() { public int getTaskCount() { return lastIndex; } + /** * Returns the task at the specified index. * @@ -63,10 +68,11 @@ public int getTaskCount() { public Task getTask(int index) { return tasks[index]; } + /** * Marks the specified task as done. * - * @param index The index of the task to mark. + * @param index The index of the task to mark. * @param isDone true to mark as done, false otherwise. */ public void markTask(int index, boolean isDone) { diff --git a/src/main/java/Todo.class b/src/main/java/Todo.class index 762beebf1..4f529c709 100644 Binary files a/src/main/java/Todo.class and b/src/main/java/Todo.class differ diff --git a/src/main/java/Todo.java b/src/main/java/Todo.java index e4ab5c972..a260ded37 100644 --- a/src/main/java/Todo.java +++ b/src/main/java/Todo.java @@ -1,7 +1,7 @@ /** * Represents a simple todo task without any specific date or time. */ -public class Todo extends Task{ +public class Todo extends Task { /** * Constructs a Todo with the specified description. * @@ -10,6 +10,7 @@ public class Todo extends Task{ public Todo(String description) { super(description); } + /** * Returns the string representation of the todo task. * @@ -19,6 +20,7 @@ public Todo(String description) { public String toString() { return "[T][" + getStatusIcon() + "] " + description; } + /** * Returns a string representation for saving the todo task to a file. * diff --git a/src/main/java/Ui.class b/src/main/java/Ui.class index cbf3c63de..e8bfcbfbd 100644 Binary files a/src/main/java/Ui.class and b/src/main/java/Ui.class differ diff --git a/src/main/java/Ui.java b/src/main/java/Ui.java index 450bf7d18..712af4ae1 100644 --- a/src/main/java/Ui.java +++ b/src/main/java/Ui.java @@ -1,5 +1,6 @@ import java.util.Scanner; import java.util.ArrayList; + /** * Handles the user interface interactions for the task management application. */ @@ -15,6 +16,7 @@ public void showWelcome() { System.out.println("Hello! I'm POIROT\nWhat can I do for you?"); showLine(); } + /** * Displays a goodbye message when exiting the application. */ @@ -28,6 +30,7 @@ public String readCommand() { Scanner scanner = new Scanner(System.in); return scanner.nextLine(); } + /** * Displays an error message to the user. * @@ -38,10 +41,11 @@ public void showError(String message) { System.out.println(message); showLine(); } + /** * Displays a message indicating that a task has been added. * - * @param task The task that was added. + * @param task The task that was added. * @param taskCount The current count of tasks in the list. */ public void showAddedTask(Task task, int taskCount) { @@ -51,10 +55,11 @@ public void showAddedTask(Task task, int taskCount) { System.out.println("Now you have " + taskCount + " tasks in the list."); showLine(); } + /** * Displays a message indicating that a task has been deleted. * - * @param task The task that was deleted. + * @param task The task that was deleted. * @param taskCount The current count of tasks in the list. */ public void showDeletedTask(Task task, int taskCount) { @@ -64,6 +69,7 @@ public void showDeletedTask(Task task, int taskCount) { System.out.println("Now you have " + taskCount + " tasks in the list."); showLine(); } + /** * Displays the list of tasks to the user. * @@ -81,6 +87,7 @@ public void showTaskList(Task[] tasks, int lastIndex) { } showLine(); } + /** * Displays a message indicating that a task has been marked as done. * @@ -93,6 +100,7 @@ public void showMarkTask(Task task) { System.out.println(task.getDescription()); showLine(); } + /** * Displays a message indicating that a task has been unmarked as done. * @@ -105,6 +113,7 @@ public void showUnmarkTask(Task task) { System.out.println(task.getDescription()); showLine(); } + /** * Displays the tasks found that match the keyword. * @@ -116,6 +125,7 @@ public void showFoundTasks(ArrayList tasks) { System.out.println((i + 1) + ". " + tasks.get(i).toString()); } } + public void showMessage(String message) { System.out.println(message); } diff --git a/src/main/java/UnmarkCommand.class b/src/main/java/UnmarkCommand.class index 5b746e6cd..5a5a0dfb0 100644 Binary files a/src/main/java/UnmarkCommand.class and b/src/main/java/UnmarkCommand.class differ diff --git a/src/main/java/UnmarkCommand.java b/src/main/java/UnmarkCommand.java index b8d66d8ab..4f1383111 100644 --- a/src/main/java/UnmarkCommand.java +++ b/src/main/java/UnmarkCommand.java @@ -1,10 +1,30 @@ +/** + * Represents a command to unmark a task as not completed in the Poirot task management system. + * This command changes the status of a task from completed to not completed. + */ public class UnmarkCommand extends Command { private int index; + /** + * Constructs a new UnmarkCommand with the specified task index. + * + * @param index The index of the task to be unmarked (1-based indexing). + */ public UnmarkCommand(int index) { this.index = index; } + /** + * Executes the unmark command. + * This method unmarks the specified task as not completed, updates the UI, + * and saves the changes to storage. + * + * @param tasks The TaskList containing all tasks. + * @param ui The UI object used to display messages to the user. + * @param storage The Storage object used to save tasks. + * @throws PoirotException If the task index is out of bounds. + */ + @Override public void execute(TaskList tasks, Ui ui, Storage storage) throws PoirotException { if (index < 1 || index > tasks.getTaskCount()) { diff --git a/src/main/java/data/duke.txt b/src/main/java/data/duke.txt index 6da49ffc3..02a909e61 100644 --- a/src/main/java/data/duke.txt +++ b/src/main/java/data/duke.txt @@ -1,7 +1,11 @@ -T | 1 | sleep +T | 0 | sleep T | 0 | work T | 0 | go to work D | 0 | t | 2025-04-01 1800 E | 0 | party | 2025-04-01 1800 | 2025-04-01 2100 D | 0 | work | 2025-04-01 1800 T | 0 | mini project +D | 0 | uation | 2024-10-31 2359 +T | 0 | go to work +D | 0 | peer evaluation | 2024-10-31 2359 +E | 0 | new party | 2024-11-21 1700 | 2024-11-23 1800