//NAME: Danish Khan //STUDENT ID: 47324012 //NAME: Adam Su //STUDENT ID: 23628358 // This is the subclass is for the Contract Employee that extends our Employee class public class contractEmployee extends Employee { //variable for how much employee makes an hour private int fixedHourlyRate; // The constructor takes a name as a parameter and uses it to initialize // the employee's name. public contractEmployee(String name, int wage) //contract employee constructor { super(name); //employee's name fixedHourlyRate = wage; //sets the employee's hourly rate to whatever wage is //inputed by the user or in the input.txt } // createWeeklyPaycheck() creates and returns a weekly paycheck for this // employee, given the number of hours that were worked this week. public Paycheck createWeeklyPaycheck(int hoursWorked) { try { if (hoursWorked < 0 || hoursWorked > 200) // hours need to be more than 0 and less than 200 throw new Exception(); } catch (Exception e) { System.out.println("Invalid amount of hours. Please try again."); System.exit(1); } int grossPay = fixedHourlyRate * hoursWorked; //gross = rate * hours worked //This is where the Paycheck of the contract employee is called to get printed out Paycheck p = new Paycheck((Employee)this, hoursWorked, grossPay, 0); //This returns the Paycheck of the contract employee return p; } // toString() returns a String representation of this employee. Different // kinds of employees will have somewhat different String representations. public String toString() { return getName() +" (Contract, " + CurrencyFormat.format(fixedHourlyRate) + "/hr)"; } }