Skip to content

Commit

Permalink
Add check for duplicate phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjohntan committed Oct 10, 2024
1 parent ad8652e commit b96b92a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,23 @@ public boolean hasSameEmail(Person otherPerson) {
return otherPerson != null && otherPerson.getEmail().equals(this.getEmail());
}

/**
* Returns true if two contacts share the same phone number.
* Checks for duplicates in phone numbers in the contact list.
*/
public boolean hasSamePhoneNumber(Person otherPerson) {
return otherPerson != null && otherPerson.getPhone().equals(this.getPhone());
}

/**
* Returns true if two contacts are considered as duplicates.
* This is to avoid adding duplicate contact in the contact list.
*
*/
public boolean hasDuplicateInfo(Person otherPerson) {
return this.isSamePerson(otherPerson) || this.hasSameEmail(otherPerson);
return this.isSamePerson(otherPerson)
|| this.hasSameEmail(otherPerson)
|| this.hasSamePhoneNumber(otherPerson);
}

/**
Expand Down

0 comments on commit b96b92a

Please sign in to comment.