Question: import java.io.*; import java.util.*; import lab7.comparators.*; import lab7.inheritance.*; public class Main { public static void main(String [] args) { ArrayListmyList = new ArrayList(); myList.add(new Programmer(Mr.
import java.io.*; import java.util.*; import lab7.comparators.*; import lab7.inheritance.*; public class Main { public static void main(String [] args) { ArrayListmyList = new ArrayList(); myList.add(new Programmer("Mr. Ima Nerd", 40000, 20000, true)); myList.add(new Programmer("Mrs. Ima Nerd", 45000, 20000, false)); myList.add(new Accountant("Mr. Bean Counter", 100000, 0, 50.00)); myList.add(new Accountant("Mrs. Bean Counter", 75000, 0, 150.00)); myList.add(new Lawyer("Mr. Lawyer", 150000, 30000, 25)); myList.add(new Lawyer("Mrs. Lawyer", 170000, 20000, 125)); System.out.println("Employee List"); for(Employee e : myList) System.out.println(e); System.out.println(); System.out.println("Employee Report"); for(Employee e : myList) e.report(); System.out.println(); Collections.sort(myList); System.out.println("Employee List: Natural Order"); for(Employee e : myList) System.out.println(e.getType() + " - " + e.getName() + " - " + e.getSalary()); System.out.println(); Collections.sort(myList, new SalaryComparator()); System.out.println("Employee List by Salary"); for(Employee e : myList) System.out.println(e.getType() + " - " + e.getName() + " - " + e.getSalary()); System.out.println(); Collections.sort(myList, new NameComparator()); System.out.println("Employee List by Name"); for(Employee e : myList) System.out.println(e.getType() + " - " + e.getName() + " - " + e.getSalary()); System.out.println(); }//end main }// end class --- public class Accountant | extends Employee The Accountant class derived from employee. Accountants get a parking stipend Field Summary: private double - parkingStipend (The parkingStipend acccountants receive) Fields inherited from class lab7.inheritance.Employee: salary Salary: BASE- private final double BASE - This is a constant representing the BASE pay and can't be changed. It is set as the first line of the constructor - private String name, protected double salary (The salary is the BASE + the additional salary) Constructor Detail: public Employee(String name,double basePayrate,double additionalPayrate) Throws:IllegalArgumentException - if any of the strings are empty or the doubles are less than 0, IllegalArgumentException - if any of the strings are null Method Detail: getParkingStipend: public double getParkingStipend(), public void report() report prints to the screen I am an accountant. I make "the salary from the base class" plus a parking stipend of "the parking stipend value" Specified by: report in class Employee, toString - public String toString(), returns Accountant: the parents toString, Overrides: toString in class Employee Returns: String --- public abstract class Employee | extends Object implements Comparable The Generic Employee Base class. There will never just be an employee NOTE: All parameters will be passed as final and all precondtions will be meField Summary: private double BASE: This is a constant representing the BASE pay and can't be changed. private String name, protected double salary (The salary is the BASE + the additional salary) Constructor Summary Employee(String name, double basePayrate, double additionalPayrate) - EVC All parameters are for the private class level variables. Method Summary int compareTo(Employee another) - compareTo first by type if the types are the same then by salary double getBaseSalary(), String getName(), double getSalary(), String getType() This methods first gets the class via getClass and then the simple name abstract void report() - The abstract method that will be overridden in the children String toString()- Simply returns the name - Methods inherited from class java.lang.Object - clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait Field Detail BASE private final double BASE- This is a constant representing the BASE pay and can't be changed. It is set as the first line of the constructor name private String name, protected double salary: The salary is the BASE + the additional salary Constructor Detail public Employee(String name,double basePayrate,double additionalPayrate) Parameters:name - The name,basePayrate - The base pay,additionalPayrate - The additonal pay Throws:IllegalArgumentException - if any of the strings are empty or the doubles are less than 0,IllegalArgumentException - if any of the strings are null Method Detail: public double getSalary(),public double getBaseSalary(), public String getName(),public String getType()- This methods first gets the class via getClass and then the simple name Returns: String the String of the simpleName- public String toString(),Overrides: toString in class Object Returns: String The name compareTo: public int compareTo(Employee another), compareTo first by type if the types are the same then by salary, Specified by: compareTo in interface Comparable, Parameters: another - - Representing the BCR to the DCO Returns: int The order Throws:IllegalArgumentException - if another is null report: public abstract void report(),The abstract method that will be overridden in the children ----- public class Lawyer | extends Employee: The lawyer class derived from employee. Lawyers get stock options NOTE: All parameters will be passed as final and all precondtions will be met Field Summary private int stockOptions Fields inherited from class lab7.Employee: salary Constructor Summary: Lawyer(String name, double basePayrate, double additionalPayrate, int stockOptions) Method Summary All MethodsInstance MethodsConcrete Methods Modifier and Type Method Description int getStockOptions() void report(): report prints to the screen I am an lawyer. String toString()- returns Lawyer: the parents toString Methods inherited from class lab7.cscd211inheritance.Employee:compareTo, getBaseSalary, getName, getSalary, getType Methods inherited from class java.lang.Object: clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait Field Detail stockOptions - private int stockOptions Constructor Detail Lawyer - public Lawyer(String name,double basePayrate,double additionalPayrate,int stockOptions) Parameters:name - The name basePayrate - The base pay additionalPayrate - The additonal pay stockOptions - The stock options Throws: IllegalArgumentException - if stock options is less than 0 Method Detail: public int getStockOptions(),p ublic void report(): report prints to the screen I am an lawyer. I get "the salary from the base class" and I have "stock options value" shares of stock. Specified by: report in class Employee - toString, public String toString()- returns Lawyer: the parents toString, Overrides: toString in class Employee Returns: String --- public class Programmer|extends Employee The Programmer class derived from employee. Accountants get a bus pass maybe NOTE: All parameters will be passed as final and all precondtions will be met Field Summary private boolean busPass:A programmer is given a bus pass Fields inherited from class lab7.inheritance.Employee: salary Constructor Summary Constructors Constructor Description Programmer(String name, double basePayrate, double additionalPayrate, boolean busPass) EVC additional parameter is a bus pass. Method Summary All MethodsInstance MethodsConcrete Methods Modifier and Type Method Description boolean getBusPass(),void report(),report prints to the screen I am a programmeString toString() returns Programmer: the parents toString Methods inherited from class lab7.inheritance.Employee:compareTo, getBaseSalary, getName, getSalary, getType Methods inherited from class java.lang.Object:clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait Field Detail busPass: private boolean busPass- A programmer is given a bus pass Constructor Detail public Programmer(String name,double basePayrate,double additionalPayrate,boolean busPass)-EVC additional parameter is a bus pass. Parameters:name - The name,basePayrate - The base pay,additionalPayrate - The additonal pay,busPass - The bus pass Method Detail public boolean getBusPass(),public void report()-report prints to the screen I am a programmer. I get "the salary from the base class" and I get a bus pass or and I do not get a bus pass, Specified by: report in class Employee, public String toString()- returns Programmer: the parents toString Overrides: toString in class Employee, Returns:String Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
