DulcetAirman icon

Person/Teacher/Student (Example)

DulcetAirman | PRO | 08/17/14 09:58:15 AM UTC | 0 ⭐ | 1012 👁️ | Never ⏰ | []
Java |

590 B

|

None

|

0 👍

/

0 👎

public abstract class Person {
  final String id;
  final String name;
 
  private String info = "I'm a  " + this.getClass().getSimpleName() + ". My ID is " + this.id
      + " and my name is " + this.name;
 
  public Person(String id, String name) {
    this.id = id;
    this.name = name;
  }
 
  public String getInfo() {
    return this.info;
  }
}
 
public final class Teacher extends Person {
  public Teacher(String id, String name) {
    super(id, name);
  }
}
 
public final class Student extends Person {
  public Student(String id, String name) {
    super(id, name);
  }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎