Skip to content
Snippets Groups Projects
Select Git revision
  • 679fc74900e28efbf58ec45de51f769cf2dba94f
  • main default protected
2 results

Person.java

Blame
  • Person.java 1.00 KiB
    package tp04;
    
    public class Person {
        private static int ID;
        private String forename;
        private String name;
            public Person(String forename, String name){
                this.name=name;
                this.forename=forename;
            }
            public int getID(){
                return this.ID;
            }
            public String toString(){
                return "(" + this.ID + ":" + this.forename + this.name + ")";
            }
            public boolean equals(Object ID){
                if (this == ID) return true;
                if(ID == null) return false;
                if(this.getClass() != ID.getClass()) return false;
                Person other = (Person) ID;
                if(this.name == null) {
                    if (other.name != null) return false;
                } else if (!this.name.equals(other.name)) return false;
                if (this.forename == null){
                    if (other.forename != null) return false;
                } else if (!this.forename.equals(other.forename)) return false;
                return true;
            }
    }