diff --git a/1ano/2semestre/poo/src/aula06/ex1/Person.java b/1ano/2semestre/poo/src/aula06/ex1/Person.java index c1b5386..4512c05 100644 --- a/1ano/2semestre/poo/src/aula06/ex1/Person.java +++ b/1ano/2semestre/poo/src/aula06/ex1/Person.java @@ -2,6 +2,8 @@ package aula06.ex1; import utils.DateYMD; +import java.util.Objects; + public class Person { private String name; private int cc; @@ -44,4 +46,17 @@ public class Person { public String toString() { return String.format("%s; CC: %d; Data de nascimento: %s", this.name, this.cc, this.birthDate); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Person person = (Person) o; + return cc == person.cc && Objects.equals(name, person.name) && Objects.equals(birthDate, person.birthDate); + } + + @Override + public int hashCode() { + return Objects.hash(name, cc, birthDate); + } }