// Zorah Fung, CSE 142 // Shows an example of Polymorphism public class EmployeeMain { public static void main(String[] args) { LegalSecretary liz = new LegalSecretary(); Employee ed = new Employee(); Secretary sally = new Secretary(); Lawyer lisa = new Lawyer(); // Can also create different types of employees and store these in variables of // type Employee. Employee sasha = new Secretary(); Employee lucas = new Lawyer(); Employee linda = new LegalSecretary(); // Because Secretary, Lawyer and LegalSecretary are all Employees, we can store these // objects in an array of Employees Employee[] employees = {liz, ed, sally, lisa, sasha, lucas, linda}; for (int i = 0; i < employees.length; i++) { printInfo(employees[i]); } } // Prints the info for an Employee. // Note: Any object that is an Employee (extends Employee) can be passed to // printInfo since they all have the methods called in printInfo public static void printInfo(Employee e) { System.out.println(e.getSalary()); System.out.println(e.getVacationDays()); System.out.println(e.getHours()); System.out.println(e.getVacationForm()); System.out.println(); } }