// Project: Patterns1 // Module: employeefactory // Source code file: empfactory/Employee.java // Illustrate the Factory software pattern. // The getInstance method can create objects from // three different classes. package empfactory; public class Employee extends Person { protected int id; protected double salary; // Constructor has package (default) accessibility. Employee( ) { } // 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(int theSalary) { salary = theSalary; } @Override public String toString( ) { return String.format("%s %d %.2f", super.toString( ), id, salary); } }