micher43

E9.8: Person, Student, & Instructor

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