Skip to content

Commit

Permalink
Update delete time message
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasTng010601 committed Nov 4, 2023
1 parent 452a479 commit 9e834be
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/model/TimeIntervalList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9e834be

Please sign in to comment.