import java.util.Objects; public abstract class Person { private String firstname; private String lastname; private String gender; private String email; public Person(String firstname, String lastname, String gender, String email) { this.firstname = firstname; this.lastname = lastname; this.gender = gender; this.email = email; } public String getFirstname() { return firstname; } public void setFirstname(String firstname) { this.firstname = firstname; } public String getLastname() { return lastname; } public void setLastname(String lastname) { this.lastname = lastname; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } @Override public String toString() { return firstname + " " + lastname; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Person other = (Person) obj; if (email == null) { if (other.email != null) return false; } else if (!email.equals(other.email)) return false; if (firstname == null) { if (other.firstname != null) return false; } else if (!firstname.equals(other.firstname)) return false; if (gender == null) { if (other.gender != null) return false; } else if (!gender.equals(other.gender)) return false; if (lastname == null) { if (other.lastname != null) return false; } else if (!lastname.equals(other.lastname)) return false; return true; } @Override public int hashCode() { return Objects.hash(firstname, lastname, gender, email); } }