Skip to content
Snippets Groups Projects
Select Git revision
  • 411c75150d502c90cfe378c6da3ee3d8ee1b615c
  • main default protected
2 results

Person.java

Blame
  • Person.java 953 B
    public class Person {
    
        private int ID;
        private String forename;
        private String name;
    
        private static int counter;
    
        public Person(String name, String forename) {
            this.forename = forename;
            this.name = name;
    
            this.ID = Person.counter;
            Person.counter++;
        }
    
        public void setName(String newName) {
            this.name = newName;
        }
    
        public String getName() {
            return this.name;
        }
    
        public void setForename(String newForename) {
            this.forename = newForename;
        }
    
        public String getForename() {
            return this.forename;
        }
    
        public int getID() {
            return this.ID;
        }
    
        public String toString() {
            return "" + this.ID + ": " + this.forename + " " + this.name;
        }
    
        public boolean equals(Object other) {
            if (other.getClass() == this.getClass()) {
                return other.ID  == this.ID;
            }
            return false;
        }
    
    }