From a2a0b1432f747c34d882b71349754095806edf7f Mon Sep 17 00:00:00 2001 From: darrenangwx Date: Tue, 14 Mar 2023 01:03:00 +0800 Subject: [PATCH 1/4] Refactored darren and stella PR --- .../AddDeadlineCommand.java | 2 +- .../DeleteDeadlineCommand.java | 2 +- .../ViewDeadlineCommand.java | 4 +-- src/main/java/common/Messages.java | 32 ++++++++----------- src/main/java/manager/DeadlineManager.java | 6 ++-- src/main/java/utils/Parser.java | 16 +++++----- .../java/dinerdirector/DinerDirectorTest.java | 12 +++---- 7 files changed, 35 insertions(+), 39 deletions(-) rename src/main/java/commands/{DeadlineCommand => deadline}/AddDeadlineCommand.java (95%) rename src/main/java/commands/{DeadlineCommand => deadline}/DeleteDeadlineCommand.java (95%) rename src/main/java/commands/{DeadlineCommand => deadline}/ViewDeadlineCommand.java (79%) diff --git a/src/main/java/commands/DeadlineCommand/AddDeadlineCommand.java b/src/main/java/commands/deadline/AddDeadlineCommand.java similarity index 95% rename from src/main/java/commands/DeadlineCommand/AddDeadlineCommand.java rename to src/main/java/commands/deadline/AddDeadlineCommand.java index 6f1c65f138..8658462000 100644 --- a/src/main/java/commands/DeadlineCommand/AddDeadlineCommand.java +++ b/src/main/java/commands/deadline/AddDeadlineCommand.java @@ -1,4 +1,4 @@ -package commands.deadlinecommand; +package commands.deadline; import entity.Deadline; import manager.DeadlineManager; diff --git a/src/main/java/commands/DeadlineCommand/DeleteDeadlineCommand.java b/src/main/java/commands/deadline/DeleteDeadlineCommand.java similarity index 95% rename from src/main/java/commands/DeadlineCommand/DeleteDeadlineCommand.java rename to src/main/java/commands/deadline/DeleteDeadlineCommand.java index 98f2bbb363..85f7f0e63b 100644 --- a/src/main/java/commands/DeadlineCommand/DeleteDeadlineCommand.java +++ b/src/main/java/commands/deadline/DeleteDeadlineCommand.java @@ -1,4 +1,4 @@ -package commands.deadlinecommand; +package commands.deadline; import manager.DeadlineManager; import ui.TextUi; diff --git a/src/main/java/commands/DeadlineCommand/ViewDeadlineCommand.java b/src/main/java/commands/deadline/ViewDeadlineCommand.java similarity index 79% rename from src/main/java/commands/DeadlineCommand/ViewDeadlineCommand.java rename to src/main/java/commands/deadline/ViewDeadlineCommand.java index 7447e167d6..cb3a7e4a65 100644 --- a/src/main/java/commands/DeadlineCommand/ViewDeadlineCommand.java +++ b/src/main/java/commands/deadline/ViewDeadlineCommand.java @@ -1,10 +1,10 @@ -package commands.deadlinecommand; +package commands.deadline; import manager.DeadlineManager; import ui.TextUi; public class ViewDeadlineCommand extends commands.Command { - public static final String COMMAND_WORD = "view_deadline"; + public static final String COMMAND_WORD = "view_deadlines"; /** * Executes the view deadline command. diff --git a/src/main/java/common/Messages.java b/src/main/java/common/Messages.java index 96b5d259bb..8dea45322b 100644 --- a/src/main/java/common/Messages.java +++ b/src/main/java/common/Messages.java @@ -28,34 +28,30 @@ public class Messages { public static final String MESSAGE_RECIPE_COMMANDS = "add_recipe n/\n" + "delete_recipe n/\n" + - "view_recipe\n"; + "view_recipes\n"; public static final String MESSAGE_WORKER_COMMANDS = "add_worker n/ w/ d/ p/\n" + "delete_worker n/\n" + "view_workers\n"; public static final String MESSAGE_COMMAND_EXIT = "Thank you for using DinerDirector!"; + public static final String MESSAGE_DEADLINE_ADDED = "Got it! This deadline has been successfully added.\n"; + public static final String MESSAGE_DEADLINE_EMPTY_LIST = "Your deadline list is empty!"; + public static final String MESSAGE_DEADLINE_VIEW_LIST = "Here are the tasks in your list:"; + public static final String MESSAGE_DEADLINE_REMOVED = "Noted. I've removed this task:\n"; + public static final String MESSAGE_NUMBER_OF_DEADLINES = "\nNow you have %d tasks in the list."; /** * Errors for programs to print. */ public static final String ERROR_COMMAND_INVALID = "Please give a valid command! " + "Type \"help\" for list of valid commands"; - - public static final String MESSAGE_DEADLINE_ADDED = "Got it! This deadline has been successfully added.\n"; - public static final String MESSAGE_EMPTY_LIST = "Your deadline list is empty!"; - public static final String MESSAGE_VIEW_LIST = "Here are the tasks in your list:"; - public static final String MESSAGE_DEADLINE_REMOVED = "Noted. I've removed this task:\n"; - public static final String MESSAGE_NUMBER_OF_DEADLINES = "\nNow you have %d tasks in the list."; - - public static final String MESSAGE_INVALID_INDEX = "Invalid task index number!\n" + - "Enter \"view_deadline\" to check the index."; - public static final String MESSAGE_MISSING_INDEX = "Delete command must be followed by the index number!" + - "Enter \"view_deadline\" to check the index."; - public static final String MESSAGE_MISSING_PARAM = "Missing deadline parameter!"; - public static final String MESSAGE_EXCESS_PARAM = "You cannot have multiple name/time for your deadline!"; - public static final String MESSAGE_EXCESS_LIST_PARAM = "Excess input detected! Please only type \"view_deadline\"."; - public static final String MESSAGE_FILE_CREATED = "Data file has been created. Your list will be saved."; - public static final String MESSAGE_FILE_LOADED = "Data file already exists. You list will be updated."; - public static final String MESSAGE_FILE_MISSING = "Data File Missing! Check if you have accidentally deleted it."; + public static final String ERROR_DEADLINE_INVALID_INDEX = "Invalid task index number!\n" + + "Enter \"view_deadlineS\" to check the index."; + public static final String ERROR_DEADLINE_MISSING_INDEX = "Delete command must be followed by the index number!" + + "Enter \"view_deadlineS\" to check the index."; + public static final String ERROR_DEADLINE_MISSING_PARAM = "Missing deadline parameter!"; + public static final String ERROR_DEADLINE_EXCESS_PARAM = "You cannot have multiple name/time for your deadline!"; + public static final String ERROR_DEADLINE_EXCESS_LIST_PARAM = + "Excess input detected! Please only type \"view_deadlineS\"."; } diff --git a/src/main/java/manager/DeadlineManager.java b/src/main/java/manager/DeadlineManager.java index d7688b1385..db76abdb07 100644 --- a/src/main/java/manager/DeadlineManager.java +++ b/src/main/java/manager/DeadlineManager.java @@ -41,9 +41,9 @@ public static void addDeadline(Deadline deadline, TextUi ui) { public static void printDeadlines(TextUi ui) { try { if (deadlines.isEmpty()) { - throw new DinerDirectorException(Messages.MESSAGE_EMPTY_LIST); + throw new DinerDirectorException(Messages.MESSAGE_DEADLINE_EMPTY_LIST); } - System.out.println(Messages.MESSAGE_VIEW_LIST); + System.out.println(Messages.MESSAGE_DEADLINE_VIEW_LIST); for (int i = 1; i <= deadlines.size(); i++) { ui.printMessage(i + ". " + deadlines.get(i - 1).toString()); } @@ -63,7 +63,7 @@ public static void deleteDeadline(int index, TextUi ui) { deadlines.remove(index); ui.printMessage(String.format(Messages.MESSAGE_NUMBER_OF_DEADLINES, deadlines.size())); } catch (IndexOutOfBoundsException e) { - System.out.println(Messages.MESSAGE_INVALID_INDEX); + System.out.println(Messages.ERROR_DEADLINE_INVALID_INDEX); } } } diff --git a/src/main/java/utils/Parser.java b/src/main/java/utils/Parser.java index 935ecd0dc9..7fe0a9ca51 100644 --- a/src/main/java/utils/Parser.java +++ b/src/main/java/utils/Parser.java @@ -1,9 +1,9 @@ package utils; import commands.Command; -import commands.deadlinecommand.AddDeadlineCommand; -import commands.deadlinecommand.ViewDeadlineCommand; -import commands.deadlinecommand.DeleteDeadlineCommand; +import commands.deadline.AddDeadlineCommand; +import commands.deadline.ViewDeadlineCommand; +import commands.deadline.DeleteDeadlineCommand; import commands.ExitCommand; import commands.HelpCommand; import commands.IncorrectCommand; @@ -52,9 +52,9 @@ private Command prepareAddDeadlineCommand(String description) { String[] testName = (description.trim()).split("n/"); try { if (((description.trim()).isEmpty()) || (!description.contains("n/")) || (words.length < 2)) { - throw new DinerDirectorException(Messages.MESSAGE_MISSING_PARAM); + throw new DinerDirectorException(Messages.ERROR_DEADLINE_MISSING_PARAM); } else if ((testName.length > 2) || (words.length > 2)) { - throw new DinerDirectorException(Messages.MESSAGE_EXCESS_PARAM); + throw new DinerDirectorException(Messages.ERROR_DEADLINE_EXCESS_PARAM); } } catch (DinerDirectorException e) { System.out.println(e); @@ -74,7 +74,7 @@ private Command prepareAddDeadlineCommand(String description) { private Command prepareViewDeadlineCommand(String userInput){ try { if(!(userInput.trim()).isEmpty()){ - throw new DinerDirectorException(Messages.MESSAGE_EXCESS_LIST_PARAM); + throw new DinerDirectorException(Messages.ERROR_DEADLINE_EXCESS_LIST_PARAM); } } catch (DinerDirectorException e) { System.out.println(e); @@ -94,10 +94,10 @@ private Command prepareDeleteDeadlineCommand(String description) { try { index = Integer.parseInt((description.trim())) - 1; if (description.isEmpty()) { - throw new DinerDirectorException(Messages.MESSAGE_MISSING_INDEX); + throw new DinerDirectorException(Messages.ERROR_DEADLINE_MISSING_INDEX); } } catch (NumberFormatException e) { - System.out.println(Messages.MESSAGE_MISSING_INDEX); + System.out.println(Messages.ERROR_DEADLINE_MISSING_INDEX); return new IncorrectCommand(); } catch (DinerDirectorException e) { System.out.println(e); diff --git a/src/test/java/dinerdirector/DinerDirectorTest.java b/src/test/java/dinerdirector/DinerDirectorTest.java index b4d56c4022..ad55dcf926 100644 --- a/src/test/java/dinerdirector/DinerDirectorTest.java +++ b/src/test/java/dinerdirector/DinerDirectorTest.java @@ -7,9 +7,9 @@ import commands.ExitCommand; import commands.HelpCommand; import commands.IncorrectCommand; -import commands.deadlinecommand.AddDeadlineCommand; -import commands.deadlinecommand.DeleteDeadlineCommand; -import commands.deadlinecommand.ViewDeadlineCommand; +import commands.deadline.AddDeadlineCommand; +import commands.deadline.DeleteDeadlineCommand; +import commands.deadline.ViewDeadlineCommand; import org.junit.jupiter.api.Test; import utils.Parser; @@ -44,8 +44,8 @@ void runCommandLoopUntilExit_userInput_deadlineCommand() { listOfCommands.add("add_deadline n/add command"); listOfCommands.add("add_deadline t/when to command"); listOfCommands.add("add_deadline n/add command t/when to command"); - listOfCommands.add("view_deadline"); - listOfCommands.add("view_deadline dsjfnskldf"); + listOfCommands.add("view_deadlines"); + listOfCommands.add("view_deadlines dsjfnskldf"); listOfCommands.add("delete_deadline"); listOfCommands.add("delete_deadline 1"); @@ -57,7 +57,7 @@ void runCommandLoopUntilExit_userInput_deadlineCommand() { listOfCommand.equals("view_deadline dsjfnskldf") || listOfCommand.equals("delete_deadline")) { assertTrue(command instanceof IncorrectCommand); - } else if (listOfCommand.equals("view_deadline")) { + } else if (listOfCommand.equals("view_deadlines")) { assertTrue(command instanceof ViewDeadlineCommand); } else if (listOfCommand.equals("add_deadline n/add command t/when to command")) { assertTrue(command instanceof AddDeadlineCommand); From 2b26c96aed479a08b696bbf75dd427e0f0e40cd6 Mon Sep 17 00:00:00 2001 From: darrenangwx Date: Tue, 14 Mar 2023 01:52:06 +0800 Subject: [PATCH 2/4] Refactor ZR code --- .../java/commands/menu/AddDishCommand.java | 2 +- .../java/commands/menu/DeleteDishCommand.java | 2 +- .../java/commands/menu/ViewDishCommand.java | 2 +- src/main/java/common/Messages.java | 16 ++++++++-------- src/main/java/utils/Parser.java | 19 ++++++++++--------- src/main/java/utils/Storage.java | 2 +- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/main/java/commands/menu/AddDishCommand.java b/src/main/java/commands/menu/AddDishCommand.java index 50669584e3..0a20f00301 100644 --- a/src/main/java/commands/menu/AddDishCommand.java +++ b/src/main/java/commands/menu/AddDishCommand.java @@ -9,7 +9,7 @@ public class AddDishCommand extends Command { - public static final String ADD_DISH_COMMAND = "add_dish"; + public static final String COMMAND_WORD = "add_dish"; private String dishName; private Integer dishPrice; private ArrayList ingredientsList; diff --git a/src/main/java/commands/menu/DeleteDishCommand.java b/src/main/java/commands/menu/DeleteDishCommand.java index 220412201d..fc18b5fa91 100644 --- a/src/main/java/commands/menu/DeleteDishCommand.java +++ b/src/main/java/commands/menu/DeleteDishCommand.java @@ -6,7 +6,7 @@ public class DeleteDishCommand extends Command { - public static final String DELETE_DISH_COMMAND = "delete_dish"; + public static final String COMMAND_WORD = "delete_dish"; private int index; public DeleteDishCommand(int index) { diff --git a/src/main/java/commands/menu/ViewDishCommand.java b/src/main/java/commands/menu/ViewDishCommand.java index 229ebcb604..a81e117a45 100644 --- a/src/main/java/commands/menu/ViewDishCommand.java +++ b/src/main/java/commands/menu/ViewDishCommand.java @@ -6,7 +6,7 @@ public class ViewDishCommand extends Command { - public static final String VIEW_DISH_COMMAND = "view_dish"; + public static final String COMMAND_WORD = "view_dish"; public ViewDishCommand() { } diff --git a/src/main/java/common/Messages.java b/src/main/java/common/Messages.java index 154edce996..284ecc67c3 100644 --- a/src/main/java/common/Messages.java +++ b/src/main/java/common/Messages.java @@ -12,7 +12,7 @@ public class Messages { "GENERIC COMMANDS:\n%s\n"+ "MEETING COMMANDS:\n%s\n"+ "DEADLINE COMMANDS:\n%s\n"+ - "RECIPE COMMANDS:\n%s\n"+ + "MENU COMMANDS:\n%s\n"+ "WORKER COMMANDS:\n%s"; public static final String MESSAGE_GENERIC_COMMANDS = "help - View list of commands\n" + @@ -26,9 +26,9 @@ public class Messages { "delete_deadline n/\n" + "view_deadlines\n"; public static final String MESSAGE_RECIPE_COMMANDS = - "add_recipe n/\n" + - "delete_recipe n/\n" + - "view_recipes\n"; + "add_dish\n" + + "delete_dish n/\n" + + "view_dish\n"; public static final String MESSAGE_WORKER_COMMANDS = "add_worker n/ w/ d/ p/\n" + "delete_worker n/\n" + @@ -54,9 +54,9 @@ public class Messages { public static final String ERROR_DEADLINE_EXCESS_LIST_PARAM = "Excess input detected! Please only type \"view_deadlineS\"."; - public static final String MESSAGE_INVALID_INDEX_FOR_DISH_COMMAND = "Your index does not contain a valid dish!"; - public static final String MESSAGE_NOT_A_VALID_INTEGER_COMMAND = "Your index has to be an integer!"; - public static final String MESSAGE_BLANK_DISH_NAME_COMMAND = "Name of dish cannot be empty!"; - public static final String MESSAGE_NEGATIVE_PRICE_COMMAND = "Price of dish cannot be negative!"; + public static final String ERROR_DISH_INVALID_INDEX = "Your index does not contain a valid dish!"; + public static final String ERROR_DISH_NOT_A_VALID_INTEGER = "Your index has to be an integer!"; + public static final String ERROR_DISH_BLANK_DISH_NAME_COMMAND = "Name of dish cannot be empty!"; + public static final String ERROR_DISH_NEGATIVE_PRICE_COMMAND = "Price of dish cannot be negative!"; } diff --git a/src/main/java/utils/Parser.java b/src/main/java/utils/Parser.java index 8648d45bc2..65f4b89fa6 100644 --- a/src/main/java/utils/Parser.java +++ b/src/main/java/utils/Parser.java @@ -21,6 +21,9 @@ import static manager.DishManager.getDishesSize; +/** + * Parser to tokenize the input + */ public class Parser { public Command parseCommand(String userInput) { @@ -28,7 +31,6 @@ public Command parseCommand(String userInput) { //Source: //https://github.com/nus-cs2113-AY2223S2/personbook/blob/main/src/main/java/seedu/personbook/parser/Parser.java //Reused the switch skeleton - String[] userInputSplit = userInput.split(" ", 2); String userInputNoCommand = userInput.replace(userInputSplit[0], ""); String commandWord = userInputSplit[0]; @@ -44,11 +46,11 @@ public Command parseCommand(String userInput) { return prepareViewDeadlineCommand(userInputNoCommand); case DeleteDeadlineCommand.COMMAND_WORD: return prepareDeleteDeadlineCommand(userInputNoCommand); - case AddDishCommand.ADD_DISH_COMMAND: + case AddDishCommand.COMMAND_WORD: return prepareAddDishCommand(); - case ViewDishCommand.VIEW_DISH_COMMAND: + case ViewDishCommand.COMMAND_WORD: return prepareViewDishCommand(); - case DeleteDishCommand.DELETE_DISH_COMMAND: + case DeleteDishCommand.COMMAND_WORD: return prepareDeleteDishCommand(userInputSplit); default: return new IncorrectCommand(); @@ -138,10 +140,10 @@ private Command prepareDeleteDishCommand(String[] userInputSplit) { try { indexToRemove = Integer.parseInt(userInputSplit[1]) - 1; if (indexToRemove < 0 || indexToRemove >= getDishesSize()) { - throw new DinerDirectorException(Messages.MESSAGE_INVALID_INDEX_FOR_DISH_COMMAND); + throw new DinerDirectorException(Messages.ERROR_DISH_INVALID_INDEX); } } catch (NumberFormatException e) { - System.out.println(Messages.MESSAGE_NOT_A_VALID_INTEGER_COMMAND); + System.out.println(Messages.ERROR_DISH_NOT_A_VALID_INTEGER); return new IncorrectCommand(); } catch (DinerDirectorException e) { System.out.println(e.getMessage()); @@ -159,7 +161,6 @@ private Command prepareAddDishCommand() { // name of dish? // price of dish? // list of ingredients, maybe indicate number of ingredients followed by listing them - String name; int price; ArrayList ingredients; @@ -169,14 +170,14 @@ private Command prepareAddDishCommand() { Scanner userInput = new Scanner(System.in); name = userInput.nextLine(); if (name.isBlank()) { - throw new DinerDirectorException(Messages.MESSAGE_BLANK_DISH_NAME_COMMAND); + throw new DinerDirectorException(Messages.ERROR_DISH_BLANK_DISH_NAME_COMMAND); } System.out.println("Price of Dish? (In cents)"); userInput = new Scanner(System.in); price = Integer.parseInt(userInput.nextLine()); if (price < 0) { - throw new DinerDirectorException(Messages.MESSAGE_NEGATIVE_PRICE_COMMAND); + throw new DinerDirectorException(Messages.ERROR_DISH_NEGATIVE_PRICE_COMMAND); } System.out.println("List of ingredients? (Separate it by spaces)"); diff --git a/src/main/java/utils/Storage.java b/src/main/java/utils/Storage.java index 2acfc2221e..8e0a9a7104 100644 --- a/src/main/java/utils/Storage.java +++ b/src/main/java/utils/Storage.java @@ -1,7 +1,7 @@ package utils; /** - * Parser to tokenize the input + * Use for storing persistent data */ public class Storage { } From 42b813e963c016734bc6d814a6addb5e0db9c966 Mon Sep 17 00:00:00 2001 From: darrenangwx Date: Tue, 14 Mar 2023 21:18:03 +0800 Subject: [PATCH 3/4] Refactor Codebase --- .../commands/deadline/AddDeadlineCommand.java | 2 ++ .../deadline/DeleteDeadlineCommand.java | 2 ++ .../deadline/ViewDeadlineCommand.java | 1 + .../meeting/DeleteMeetingCommand.java | 8 +++--- .../commands/meeting/ViewMeetingCommand.java | 4 ++- .../java/commands/staff/AddStaffCommand.java | 7 ++--- .../java/commands/staff/ViewStaffCommand.java | 1 + src/main/java/entity/Deadline.java | 4 ++- src/main/java/manager/DeadlineManager.java | 12 ++++++--- src/main/java/manager/MeetingManager.java | 27 ++++++++++--------- src/main/java/manager/StaffManager.java | 15 ++++++----- src/main/java/ui/TextUi.java | 1 + src/main/java/utils/Parser.java | 13 ++++++--- .../java/dinerdirector/DinerDirectorTest.java | 4 +-- 14 files changed, 64 insertions(+), 37 deletions(-) diff --git a/src/main/java/commands/deadline/AddDeadlineCommand.java b/src/main/java/commands/deadline/AddDeadlineCommand.java index 8658462000..c6362b1009 100644 --- a/src/main/java/commands/deadline/AddDeadlineCommand.java +++ b/src/main/java/commands/deadline/AddDeadlineCommand.java @@ -10,6 +10,7 @@ public class AddDeadlineCommand extends commands.Command { /** * Creates an add deadline command that adds the deadline item being passed through. + * * @param deadline the deadline to add to the list. */ public AddDeadlineCommand(Deadline deadline) { @@ -18,6 +19,7 @@ public AddDeadlineCommand(Deadline deadline) { /** * Executes the add deadline command. + * * @param ui manages user input. */ @Override diff --git a/src/main/java/commands/deadline/DeleteDeadlineCommand.java b/src/main/java/commands/deadline/DeleteDeadlineCommand.java index 85f7f0e63b..d993c496b4 100644 --- a/src/main/java/commands/deadline/DeleteDeadlineCommand.java +++ b/src/main/java/commands/deadline/DeleteDeadlineCommand.java @@ -9,6 +9,7 @@ public class DeleteDeadlineCommand extends commands.Command { /** * Creates a delete deadline command that deletes the deadline item of the index being passed through. + * * @param index the index of the deadline item to delete. */ public DeleteDeadlineCommand(int index) { @@ -17,6 +18,7 @@ public DeleteDeadlineCommand(int index) { /** * Executes the delete deadline command. + * * @param ui manages user input. */ @Override diff --git a/src/main/java/commands/deadline/ViewDeadlineCommand.java b/src/main/java/commands/deadline/ViewDeadlineCommand.java index cb3a7e4a65..9c7d85d91d 100644 --- a/src/main/java/commands/deadline/ViewDeadlineCommand.java +++ b/src/main/java/commands/deadline/ViewDeadlineCommand.java @@ -8,6 +8,7 @@ public class ViewDeadlineCommand extends commands.Command { /** * Executes the view deadline command. + * * @param ui manages user input. */ @Override diff --git a/src/main/java/commands/meeting/DeleteMeetingCommand.java b/src/main/java/commands/meeting/DeleteMeetingCommand.java index 5911829e99..9fd135b984 100644 --- a/src/main/java/commands/meeting/DeleteMeetingCommand.java +++ b/src/main/java/commands/meeting/DeleteMeetingCommand.java @@ -19,10 +19,10 @@ public boolean isExit() { @Override public void execute(TextUi ui) { - boolean hasDelete=MeetingManager.deleteMeeting(issue); - if(hasDelete){ - ui.printMessage(issue+" deleted"); - } else{ + boolean hasDelete = MeetingManager.deleteMeeting(issue); + if (hasDelete) { + ui.printMessage(issue + " deleted"); + } else { ui.printMessage("Sorry! There's no such meeting"); } } diff --git a/src/main/java/commands/meeting/ViewMeetingCommand.java b/src/main/java/commands/meeting/ViewMeetingCommand.java index 9bed778826..d17637478a 100644 --- a/src/main/java/commands/meeting/ViewMeetingCommand.java +++ b/src/main/java/commands/meeting/ViewMeetingCommand.java @@ -6,11 +6,13 @@ import ui.TextUi; public class ViewMeetingCommand extends Command { - public static final String COMMAND_WORD="view_meetings"; + public static final String COMMAND_WORD = "view_meetings"; + @Override public boolean isExit() { return false; } + @Override public void execute(TextUi ui) { ui.printMessage(Messages.MESSAGE_MEETING_VIEW_LIST); diff --git a/src/main/java/commands/staff/AddStaffCommand.java b/src/main/java/commands/staff/AddStaffCommand.java index 63db9b7847..08743f9ef9 100644 --- a/src/main/java/commands/staff/AddStaffCommand.java +++ b/src/main/java/commands/staff/AddStaffCommand.java @@ -11,7 +11,8 @@ public class AddStaffCommand extends Command { private String workingDay; private String phoneNumber; private String dateOfBirth; - public AddStaffCommand(String name, String workingDay, String phoneNumber, String dateOfBirth){ + + public AddStaffCommand(String name, String workingDay, String phoneNumber, String dateOfBirth) { this.name = name; this.workingDay = workingDay; this.phoneNumber = phoneNumber; @@ -19,14 +20,14 @@ public AddStaffCommand(String name, String workingDay, String phoneNumber, Strin } @Override - public void execute (TextUi ui){ + public void execute(TextUi ui) { Staff staff = new Staff(this.name, this.workingDay, this.phoneNumber, this.dateOfBirth); StaffManager.addStaff(staff); ui.printMessage(staff + " added!"); } @Override - public boolean isExit (){ + public boolean isExit() { return false; } } diff --git a/src/main/java/commands/staff/ViewStaffCommand.java b/src/main/java/commands/staff/ViewStaffCommand.java index 54ec4bb518..cc475c2e3e 100644 --- a/src/main/java/commands/staff/ViewStaffCommand.java +++ b/src/main/java/commands/staff/ViewStaffCommand.java @@ -6,6 +6,7 @@ public class ViewStaffCommand extends Command { public static final String COMMAND_WORD = "view_staff"; + public ViewStaffCommand() { } diff --git a/src/main/java/entity/Deadline.java b/src/main/java/entity/Deadline.java index e6f4cdb5a0..09fa27493f 100644 --- a/src/main/java/entity/Deadline.java +++ b/src/main/java/entity/Deadline.java @@ -6,8 +6,9 @@ public class Deadline { /** * Creates a deadline item with the deadline description and deadline timing passed through. + * * @param description the description of deadline item. - * @param dueDate the deadline of the deadline item. + * @param dueDate the deadline of the deadline item. */ public Deadline(String description, String dueDate) { this.description = description; @@ -16,6 +17,7 @@ public Deadline(String description, String dueDate) { /** * Returns a String of the deadline and due date for the deadline item in a special format. + * * @return the string */ public String toString() { diff --git a/src/main/java/manager/DeadlineManager.java b/src/main/java/manager/DeadlineManager.java index db76abdb07..e2d2f95a5d 100644 --- a/src/main/java/manager/DeadlineManager.java +++ b/src/main/java/manager/DeadlineManager.java @@ -14,6 +14,7 @@ public class DeadlineManager { /** * Creates DeadlineList with input list. + * * @param deadlines list of deadlines. */ public DeadlineManager(ArrayList deadlines) { @@ -22,20 +23,22 @@ public DeadlineManager(ArrayList deadlines) { /** * Adds a deadline item to the deadline list. + * * @param deadline the deadline item to be added. - * @param ui manages user output. + * @param ui manages user output. */ public static void addDeadline(Deadline deadline, TextUi ui) { deadlines.add(deadline); //Solution below adapted from https://github.com/darrenangwx/ip/blob/6d3f1bc5f1 // a281f9459a67650b043705d3096a8f/src/main/java/task/TaskParser.java ui.printMessage(Messages.MESSAGE_DEADLINE_ADDED + - deadlines.get(deadlines.size()-1).toString() + + deadlines.get(deadlines.size() - 1).toString() + String.format(Messages.MESSAGE_NUMBER_OF_DEADLINES, deadlines.size())); } /** * Print the task list. + * * @param ui manages user output. */ public static void printDeadlines(TextUi ui) { @@ -47,15 +50,16 @@ public static void printDeadlines(TextUi ui) { for (int i = 1; i <= deadlines.size(); i++) { ui.printMessage(i + ". " + deadlines.get(i - 1).toString()); } - } catch (DinerDirectorException e){ + } catch (DinerDirectorException e) { System.out.println(e); } } /** * Deletes a task from the task list. + * * @param index index of deadline to be deleted. - * @param ui manages user output. + * @param ui manages user output. */ public static void deleteDeadline(int index, TextUi ui) { try { diff --git a/src/main/java/manager/MeetingManager.java b/src/main/java/manager/MeetingManager.java index 9975aa94e7..a46d3fc548 100644 --- a/src/main/java/manager/MeetingManager.java +++ b/src/main/java/manager/MeetingManager.java @@ -5,24 +5,27 @@ import java.util.ArrayList; public class MeetingManager { - private static ArrayList meetings=new ArrayList(); - public static void addMeeting(Meeting meeting){ + private static ArrayList meetings = new ArrayList(); + + public static void addMeeting(Meeting meeting) { meetings.add(meeting); } - public static String printMeetings(){ - String meetingList=""; - for(Meeting meeting:meetings){ - meetingList+=meeting.getIssue()+" at "+meeting.getTime()+System.lineSeparator(); + + public static String printMeetings() { + String meetingList = ""; + for (Meeting meeting : meetings) { + meetingList += meeting.getIssue() + " at " + meeting.getTime() + System.lineSeparator(); } return meetingList; } - public static boolean deleteMeeting(String issue) { - boolean hasMeeting=false; - for(int i=0;i Date: Tue, 14 Mar 2023 21:26:59 +0800 Subject: [PATCH 4/4] Update Help menu --- src/main/java/common/Messages.java | 46 +++++++++++++----------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/main/java/common/Messages.java b/src/main/java/common/Messages.java index d088eef9bb..eff4889e17 100644 --- a/src/main/java/common/Messages.java +++ b/src/main/java/common/Messages.java @@ -7,32 +7,26 @@ public class Messages { /** * Messages for programs to print. */ - public static final String MESSAGE_VALID_COMMAND_LIST = - "List of valid commands:\n" + - "GENERIC COMMANDS:\n%s\n" + - "MEETING COMMANDS:\n%s\n" + - "DEADLINE COMMANDS:\n%s\n" + - "MENU COMMANDS:\n%s\n" + - "STAFF COMMANDS:\n%s"; - public static final String MESSAGE_GENERIC_COMMANDS = - "help - View list of commands\n" + - "exit - exits the program\n"; - public static final String MESSAGE_MEETING_COMMANDS = - "add_meeting n/ t/