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

Implement duplicate email checking feature #53

Merged

Conversation

CYX22222003
Copy link

Fix #45

@CYX22222003 CYX22222003 added this to the v1.2 milestone Oct 10, 2024
@CYX22222003 CYX22222003 self-assigned this Oct 10, 2024
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ Complexity Δ
...c/main/java/seedu/address/model/person/Person.java 97.36% <100.00%> (+0.14%) 25.00 <6.00> (+6.00)
...a/seedu/address/model/person/UniquePersonList.java 86.95% <100.00%> (ø) 20.00 <0.00> (ø)

... and 7 files with indirect coverage changes

@CYX22222003 CYX22222003 marked this pull request as ready for review October 10, 2024 06:56
@CYX22222003 CYX22222003 added type.Enhancement An enhancement to an existing story priority.High Must do labels Oct 10, 2024
Copy link

@KrashKart KrashKart left a comment

Choose a reason for hiding this comment

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

LGTM! This should be sufficient to check if a Person has the same name and email as one in the list.

@@ -33,7 +33,7 @@ public class UniquePersonList implements Iterable<Person> {
*/
public boolean contains(Person toCheck) {
requireNonNull(toCheck);
return internalList.stream().anyMatch(toCheck::isSamePerson);
return internalList.stream().anyMatch(toCheck::hasDuplicateInfo);

Choose a reason for hiding this comment

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

This should check if the list has any Person with the same email and name

* This is to avoid adding duplicate contact in the contact list.
*/
public boolean hasDuplicateInfo(Person otherPerson) {
return this.isSamePerson(otherPerson) || this.hasSameEmail(otherPerson);

Choose a reason for hiding this comment

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

This checks for both the name and the email

@KrashKart KrashKart merged commit 8da6efe into AY2425S1-CS2103T-F14a-4:master Oct 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority.High Must do type.Enhancement An enhancement to an existing story
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check for duplicate email
2 participants