From 9e834be1a3ba6fca7a8cec3b061ed988b5040cf1 Mon Sep 17 00:00:00 2001 From: NicholasTng010601 <nicholastng@hotmail.com> Date: Sat, 4 Nov 2023 12:11:33 +0800 Subject: [PATCH] Update delete time message --- .../address/logic/commands/DeleteGroupTimeCommand.java | 5 +++-- .../address/logic/commands/DeletePersonTimeCommand.java | 6 +++--- .../seedu/address/logic/commands/DeleteTimeCommand.java | 2 +- src/main/java/seedu/address/model/ModelManager.java | 8 ++++---- src/main/java/seedu/address/model/TimeIntervalList.java | 6 +++--- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/DeleteGroupTimeCommand.java b/src/main/java/seedu/address/logic/commands/DeleteGroupTimeCommand.java index 71f858ff12b..ae76d682c6e 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteGroupTimeCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteGroupTimeCommand.java @@ -26,12 +26,13 @@ public DeleteGroupTimeCommand(Group group, ArrayList<TimeInterval> timeIntervals @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + String commandOutcome; if (model.hasGroup(group)) { - model.deleteTimeFromGroup(group, timeIntervalsToDelete); + commandOutcome = model.deleteTimeFromGroup(group, timeIntervalsToDelete); } else { throw new CommandException("Group does not exists"); } - return new CommandResult(String.format(MESSAGE_DELETE_TIME_SUCCESS, group.getGroupName())); + return new CommandResult(String.format(MESSAGE_DELETE_TIME + "\n" + commandOutcome, group.getGroupName())); } @Override diff --git a/src/main/java/seedu/address/logic/commands/DeletePersonTimeCommand.java b/src/main/java/seedu/address/logic/commands/DeletePersonTimeCommand.java index 202194495a5..b2b878d19c4 100644 --- a/src/main/java/seedu/address/logic/commands/DeletePersonTimeCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeletePersonTimeCommand.java @@ -26,13 +26,13 @@ public DeletePersonTimeCommand(Name personName, ArrayList<TimeInterval> timeInte @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - String status; + String commandOutcome; if (model.hasPerson(personName)) { - status = model.deleteTimeFromPerson(personName, timeIntervalsToDelete); + commandOutcome = model.deleteTimeFromPerson(personName, timeIntervalsToDelete); } else { throw new CommandException("Person does not exist \n"); } - return new CommandResult(String.format(MESSAGE_DELETE_TIME_SUCCESS + status, personName.fullName)); + return new CommandResult(String.format(MESSAGE_DELETE_TIME + "\n" + commandOutcome, personName.toString())); } @Override diff --git a/src/main/java/seedu/address/logic/commands/DeleteTimeCommand.java b/src/main/java/seedu/address/logic/commands/DeleteTimeCommand.java index fda0b1e1989..70bb0397a82 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteTimeCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteTimeCommand.java @@ -9,7 +9,7 @@ * Deletes time from the individual and group. */ public abstract class DeleteTimeCommand extends Command { - public static final String MESSAGE_DELETE_TIME_SUCCESS = "Deleted Time from: %1$s"; + public static final String MESSAGE_DELETE_TIME = "Attempted to delete Time from: %1$s"; public static final String COMMAND_WORD = "deletetime"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Deletes free time from an existing person or group. \n" + "For person, parameters: " diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 36d305542b7..f77d220e7f6 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -191,9 +191,9 @@ public String deleteTimeFromPerson(Name personName, requireNonNull(personName); Person person = addressBook.getPerson(personName.fullName); try { - String status = person.deleteFreeTime(toDeleteTime); + String commandOutcome = person.deleteFreeTime(toDeleteTime); forceUpdateList(); - return status; + return commandOutcome; } catch (CommandException e) { throw new CommandException(e.getMessage()); } @@ -262,9 +262,9 @@ public String deleteTimeFromGroup(Group group, requireNonNull(group); Group groupToDeleteTime = addressBook.getGroup(group.getGroupName()); try { - String status = groupToDeleteTime.deleteTime(toDeleteTime); + String commandOutcome = groupToDeleteTime.deleteTime(toDeleteTime); forceUpdateList(); - return status; + return commandOutcome; } catch (CommandException e) { forceUpdateList(); throw new CommandException(e.getMessage()); diff --git a/src/main/java/seedu/address/model/TimeIntervalList.java b/src/main/java/seedu/address/model/TimeIntervalList.java index cb11413a537..e23ec944029 100644 --- a/src/main/java/seedu/address/model/TimeIntervalList.java +++ b/src/main/java/seedu/address/model/TimeIntervalList.java @@ -31,7 +31,7 @@ public Stream<TimeInterval> toStream() { public String addTime(ArrayList<TimeInterval> timeIntervals) throws CommandException{ boolean isPass = false; boolean isFail = false; - StringBuilder errorMessage = new StringBuilder("There is a clash in these input timings with your existing timing:\n"); + StringBuilder errorMessage = new StringBuilder("There is a clash in these input timings with your existing timings:\n"); StringBuilder passMessage = new StringBuilder("These times have been added:\n"); for (TimeInterval interval : timeIntervals) { if (isTimeIntervalOverlap(interval)) { @@ -62,8 +62,8 @@ public void addAll(TimeIntervalList timeIntervalList) { public String deleteTime(ArrayList<TimeInterval> timeIntervals) throws CommandException { boolean isPass = false; boolean isFail = false; - StringBuilder errorMessage = new StringBuilder("These times are not in the list:\n"); - StringBuilder passMessage = new StringBuilder("These times have been added:\n"); + StringBuilder errorMessage = new StringBuilder("These times were not in the list:\n"); + StringBuilder passMessage = new StringBuilder("These times have been deleted:\n"); for (TimeInterval interval : timeIntervals) { if (!internalList.contains(interval)) { isFail = true;