// Project: Patterns1 // Module: employeefactory // Source code file: empfactory/Executive.java // Illustrate the Factory software pattern. // The getInstance method can create objects from // three different classes. package empfactory; public class Executive extends Employee { private double bonus; // Constructor has package (default) accessibility. Executive( ) { } // Only define setters, no getters. public void setName(String theName) { name = theName; } public void setGender(char theGender) { gender = theGender; } public void setAge(int theAge) { age = theAge; } public void setId(int theId) { id = theId; } public void setSalary(double theSalary) { salary = theSalary; } public void setBonus(double theBonus) { bonus = theBonus; } @Override public String toString() { return String.format("%s %.2f", super.toString(), bonus); } }