diff --git a/src/main/java/lars/command/HelpCommand.java b/src/main/java/lars/command/HelpCommand.java new file mode 100644 index 0000000000..b4e47c06eb --- /dev/null +++ b/src/main/java/lars/command/HelpCommand.java @@ -0,0 +1,39 @@ +package lars.command; + +import lars.storage.Storage; +import lars.task.TaskList; +import lars.ui.Ui; + +/** + * Represents a command that displays a help message listing all available commands and their formats. + * This command guides the user on how to interact with the Lars application effectively. + */ +public class HelpCommand extends Command { + + @Override + public void execute(TaskList tasks, Ui ui, Storage storage) { + this.response = + "Here are the commands you can use:\n\n" + + "1. list\n\n" + + + "2. todo \n" + + " 👉Example:\n" + + " todo read book\n\n" + + + "3. deadline /by \n" + + " 👉Examples:\n" + + " 1. deadline submit report /by 2026-02-15\n" + + " 2. deadline return library book /by 2026-02-15 1800\n" + + " 3. deadline return library book /by Sunday\n\n" + + + "4. event /from /to \n" + + " 👉Example:\n" + + " event meeting /from 2pm /to 4pm\n\n" + + + "5. mark \n" + + "6. unmark \n" + + "7. delete \n" + + "8. remind (or press ⏰)\n" + + "9. bye"; + } +} diff --git a/src/main/java/lars/parser/Parser.java b/src/main/java/lars/parser/Parser.java index 6ed3dc0f85..55e254b921 100644 --- a/src/main/java/lars/parser/Parser.java +++ b/src/main/java/lars/parser/Parser.java @@ -6,6 +6,7 @@ import lars.command.Command; import lars.command.DeleteCommand; import lars.command.ExitCommand; +import lars.command.HelpCommand; import lars.command.ListCommand; import lars.command.MarkCommand; import lars.command.RemindCommand; @@ -101,6 +102,10 @@ public static Command parse(String fullCommand) throws LarsException { case "remind": return new RemindCommand(); + + case "help": + return new HelpCommand(); + default: throw new LarsException("I'm sorry, but I don't know what that means :-("); } diff --git a/src/main/java/lars/ui/Ui.java b/src/main/java/lars/ui/Ui.java index 0a379fb33b..cd7ae833c2 100644 --- a/src/main/java/lars/ui/Ui.java +++ b/src/main/java/lars/ui/Ui.java @@ -29,9 +29,9 @@ public void printLine() { /** * Returns the welcome message shown to the user. */ - // 在 Ui.java 中添加 public String getWelcomeMessage() { - return "Hello! I'm Lars\nWhat can I do for you?"; + return "Hello! I'm Lars 💛💜\nSo glad to see you\n" + + "You can type \"help\" to see what I can do 🧞‍"; } /**