Skip to content

Commit

Permalink
Merge pull request #151 from AndrewJanong/duplicate-person-bug
Browse files Browse the repository at this point in the history
Change equals and isSamePerson method
  • Loading branch information
zekone authored Nov 8, 2023
2 parents 3152098 + 1fba949 commit e264b99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ public boolean isSamePerson(Person otherPerson) {
return false;
}

// Checks everything except tags
return name.equals(otherPerson.name)
&& phone.equals(otherPerson.phone)
&& email.equals(otherPerson.email)
&& address.equals(otherPerson.address)
&& tags.equals(otherPerson.tags);
&& address.equals(otherPerson.address);
}

/**
Expand All @@ -215,8 +215,7 @@ public boolean equals(Object other) {
return name.equals(otherPerson.name)
&& phone.equals(otherPerson.phone)
&& email.equals(otherPerson.email)
&& address.equals(otherPerson.address)
&& tags.equals(otherPerson.tags);
&& address.equals(otherPerson.address);
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/seedu/address/model/person/PersonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public void isSamePerson() {
editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build();
assertFalse(ALICE.equals(editedAlice));

// different tags -> returns false
// different tags -> returns true
editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build();
assertFalse(ALICE.equals(editedAlice));
assertTrue(ALICE.equals(editedAlice));
}

@Test
Expand Down Expand Up @@ -109,9 +109,9 @@ public void equals() {
editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build();
assertFalse(ALICE.equals(editedAlice));

// different tags -> returns false
// different tags -> returns true
editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build();
assertFalse(ALICE.equals(editedAlice));
assertTrue(ALICE.equals(editedAlice));
}

@Test
Expand Down

0 comments on commit e264b99

Please sign in to comment.