Advertisement
JoshJurban

Exercise 9.8

Dec 2nd, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. //Person Superclass
  2. public class Person
  3. {
  4.     public String name;
  5.     public int yearOfBirth;
  6.    
  7.     public Person (String personName, int personYearOfBirth)
  8.     {
  9.         name = personName;
  10.         yearOfBirth = personYearOfBirth;
  11.     }
  12.    
  13.     public String toString()
  14.     {
  15.         String dob = Integer.toString(yearOfBirth);
  16.         return name;
  17.     }
  18. }  
  19.  
  20. //Instructor subclass
  21. public class Instructor extends Person
  22. {
  23.     public double salary;
  24.    
  25.     public Instructor (String personName, int personYearOfBirth)
  26.     {
  27.         super(personName, personYearOfBirth);
  28.     }
  29.    
  30.     public void setSalary(int personSalary)
  31.     {
  32.         salary = personSalary;
  33.     }
  34. }
  35.  
  36. //Student subclass
  37. public class Student extends Person
  38. {
  39.     public String major;
  40.    
  41.     public Student(String personName, int personYearOfBirth)
  42.     {
  43.         super(personName, personYearOfBirth);
  44.     }
  45.    
  46.     public void setMajor(String personMajor)
  47.     {
  48.         major = personMajor;
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement