Skip to content

Commit

Permalink
Merge pull request AY2324S2-CS2103-F15-2#81 from Hwww23/resolve_bug
Browse files Browse the repository at this point in the history
Update EditCommand.java and Person.java
zoebelle-pang authored Apr 3, 2024
2 parents 4779f3e + 761820b commit 48d74e5
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ public CommandResult execute(Model model) throws CommandException {
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
}

if (model.hasDateTime(editedPerson)) {
if (!personToEdit.isSameDateTime(editedPerson) && model.hasDateTime(editedPerson)) {
throw new CommandException(MESSAGE_DUPLICATE_DATETIME);
}

12 changes: 12 additions & 0 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
@@ -103,6 +103,18 @@ public boolean isSamePerson(Person otherPerson) {
&& otherPerson.getName().equals(getName());
}

/**
* Returns true if both persons have the same set of datetime.
*/
public boolean isSameDateTime(Person otherPerson) {
if (otherPerson == this) {
return true;
}

return otherPerson != null
&& otherPerson.getDateTimes().equals(getDateTimes());
}

/**
* Returns true if both persons have the same identity and data fields.
* This defines a stronger notion of equality between two persons.

0 comments on commit 48d74e5

Please sign in to comment.