Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Person Superclass
- public class Person
- {
- public String name;
- public int yearOfBirth;
- public Person (String personName, int personYearOfBirth)
- {
- name = personName;
- yearOfBirth = personYearOfBirth;
- }
- public String toString()
- {
- String dob = Integer.toString(yearOfBirth);
- return name;
- }
- }
- //Instructor subclass
- public class Instructor extends Person
- {
- public double salary;
- public Instructor (String personName, int personYearOfBirth)
- {
- super(personName, personYearOfBirth);
- }
- public void setSalary(int personSalary)
- {
- salary = personSalary;
- }
- }
- //Student subclass
- public class Student extends Person
- {
- public String major;
- public Student(String personName, int personYearOfBirth)
- {
- super(personName, personYearOfBirth);
- }
- public void setMajor(String personMajor)
- {
- major = personMajor;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement