Advertisement
DulcetAirman

Person/Teacher/Student (Example)

Aug 17th, 2014
319
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public abstract class Person {
  2.   final String id;
  3.   final String name;
  4.  
  5.   private String info = "I'm a  " + this.getClass().getSimpleName() + ". My ID is " + this.id
  6.       + " and my name is " + this.name;
  7.  
  8.   public Person(String id, String name) {
  9.     this.id = id;
  10.     this.name = name;
  11.   }
  12.  
  13.   public String getInfo() {
  14.     return this.info;
  15.   }
  16. }
  17.  
  18. public final class Teacher extends Person {
  19.   public Teacher(String id, String name) {
  20.     super(id, name);
  21.   }
  22. }
  23.  
  24. public final class Student extends Person {
  25.   public Student(String id, String name) {
  26.     super(id, name);
  27.   }
  28. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement