Skip to content
Snippets Groups Projects
Commit e00afa12 authored by Joel Cavat's avatar Joel Cavat
Browse files

Add chapt. 5

parent 43563f3f
No related branches found
No related tags found
No related merge requests found
File added
File added
class Person {
protected int id;
protected String name;
public Person(int id, String name) {
this.id = id; this.name = name;
}
@Override public String toString() {
return "Person(" + this.id + ", " + this.name + ")";
}
@Override public boolean equals(Object o) {
if(this == o) return true;
if(o == null || !(o instanceof Person)) {
return false; }
Person p = (Person)o;
return p.id == this.id && p.name.equals(this.name);
}
}
class Patient extends Person {
public Patient(int id, String name) {
super(id, name);
}
@Override public String toString() {
return "Patient(" + this.id + ", " + this.name + ")";
}
@Override public boolean equals(Object o) {
if(this == o) return true;
if(o == null || !(o instanceof Patient)) {
return false; }
Patient p = (Patient)o;
return p.id == this.id && p.name.equals(this.name);
}
}
public class EqualsMain {
public static void main(String[] args) {
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment