Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EditCommand.java and Person.java #81

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

throw new CommandException(MESSAGE_DUPLICATE_DATETIME);
}

Expand Down
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
Expand Up @@ -103,6 +103,18 @@
&& otherPerson.getName().equals(getName());
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition of this method, Logic is well handled. Good job!

if (otherPerson == this) {
return true;

Check warning on line 111 in src/main/java/seedu/address/model/person/Person.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/Person.java#L111

Added line #L111 was not covered by tests
}

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.
Expand Down
Loading