Question: //*Manager.java*// public interface Manager { public void handleCrisis(); } _________________________________________________________ /**Employee.java**/ Public abstract class Employee { protected final String name; protected final int id; public

 //*Manager.java*// public interface Manager { public void handleCrisis(); } _________________________________________________________ /**Employee.java**/

Public abstract class Employee { protected final String name; protected final int

id; public Employee(String empName, int empId) { name = empName; id =

//*Manager.java*// public interface Manager { public void handleCrisis(); }
_________________________________________________________ /**Employee.java**/ Public abstract class Employee { protected final String name; protected final int id; public Employee(String empName, int empId) { name = empName; id = empId; } public Employee() { name = generatedNames[lastGeneratedId]; id = lastGeneratedId++; } public String getName() { return name; } public int getId() { return id; } //returns true if work was successful. otherwise returns false (crisis) public abstract boolean work(); public String toString() { return name + " ID: " + id; } public boolean equals(Object other) { if (other instanceof Employee) { return equals((Employee)other); } return false; } public boolean equals(Employee other) { return other != null && name.equals(other.name) && id == other.id; } private static int lastGeneratedId = 0; private static String[] generatedNames = { "Leon Mcdonald", "Frankie Johnson", "Todd Rosenthal", "Mauricio Curran", "Randy Feinstein", "Donald Munoz", "Bonnie Barnhardt", "Gary Foley", "Brittney Wilson", "Lyndsay Loomis", "Madge Cartwright", "Stella Coan", "David Lafave", "Kimberly Matthews", "Dwayne Heckler", "Laura Payne", "Mary Luevano", "Walter Sizemore", "James Lawson", "Pat Nelson", "Sherry Leighton", "Anthony Tieman", "Lona Davis", "Ana Flores", "Richard Mcdonald", "Joseph Standley", "Nancy Eddy", "Joyce Shaw", "Philip Collings", "James Reay", "Barbara Acker", "Violet Cleary", "Maria Crawley", "Erin Hilton", "Evelyn Morales", "Leo Rose", "Dorothy Johnson", "Geoffrey Fogarty", "Jane Marin", "Daniel Tran", "Nancy Lee", "Peter Johnson", "Glenn Browning", "Mark Jaramillo", "Latina Gross", "Theresa Stutes", "George Thiel", "Robert Carney", "Janet Watts", "Michael English", "James Scott", "Elmer Honaker", "Brian Upton", "Dawne Miller", "Gretchen Bender", "John Carr", "Faith Gavin", "Traci Hill", "Joseph Miller", "Don Montoya", "Brandy Pritts", "Sandra Sheppard", "Charles Whitmer", "Ana Williams", "Elizabeth Murphy", "Michael Hollingsworth", "Claudine Dalton", "Harold Coleman", "Young Ayala", "Shelba Kirschbaum", "Tom Perez", "Amee Martin", "Maryanne Foote", "Sylvia Harrell", "Alexander Weibel", "Bruce Bailey", "Vincent Fidler", "Jack Wilbur", "Charles Pond", "Danielle Yocom", "John Kemp", "Jamie Casey", "Everett Frederick", "Emma Hazley", "Justin Lynch", "Tyler Miller", "Albert Reyes", "Wilbur Price", "Kimberly Halton", "Mary Underwood", "Raymond Garrett", "William Olive", "Joanne Smith", "Wilbert Howerton", "Selene Gross", "Jennie Andrews", "Jasper Barrows", "Robert Verdin", "Mark Mcallister", "Teri Morrissey" }; }

---------------------------------------------------------------------------------------------

//*CompanyStimulator.java*// import java.util.ArrayList; import java.util.Random; public class CompanySimulator { private int currentTime; private ArrayList company; private void initCompany() { company = new ArrayList(); company.add(new Executive()); for (int i = 0; i   SoftwareEngineer The SoftwareEngineer class inherits from Employee as noted by the extends keyword in the class declaration. Software engineers implement the work method in the following way: engineers happily program, but cause a criss 0% of the time. For our purposes, programming is defined as a simple am programming print statement that identifies the engineer using toString You can generate a crisis by returning false. Otherwise, return true. Use the following code snippet to determine if a crisis should be generated: Random crisisGennew Random) if (crisisGen.nextInt (10)0) /it's a crisis! else //everything is oK! nextInt generates a random integer in the range [0, n-1]. In the above example, n-10. Crises are detected by the simulation code and triggers a call to CompanySimulator.manageCrisis(Employee emp) that you will implement. We will discuss the method further shortly. Tasks Create the class SoftwareEngineer and inherit from Employee. Implement the work0 method with an appropriate print statement: who this object represents and "I am programming" Implement the two SoftwareEngineer constructors: SoftwareEngineer0 and SoftwareEngineer(String empName, int empId). Make sure to call their respective super class constructor . Implement toString. Prefix the result of the Employee's toString with "SoftwareEngineer" SoftwareManager and the Manager Interface The SoftwareManager is a specialization of SoftwareEngineer. Because the manager inherits from the engineer class, it is also an Employee. Note that in this example, our organization hierachy (managers are in charge of engineers), is the opposite of the class hiearchy. This is because the manager can perform engineering tasks (programming) and distinct management tasks. In this lab, management tasks are defined by the Manager interface. Manager defines a single method: handleCrisis. The SoftwareManager not only inherits from a parent class, but also conforms to the Manager interface. In Java, classes are only allowed to inherit from a single parent class. However, classes may implement an arbitrary number of interfaces to simulate the multiple inheritance features of other languages while mitigating some of the problems that often arise. Tasks Create the class SoftwareManager. You should inherit from SoftwareEngineer and implement the Manager interface. . Implement work0 and handleCrisis0 with appropriate print statements: who this object represents and "I am programming" or "handling a crisis". How many methods do you need to write? Implement the two SoftwareManager constructors: SoftwareManager0 and SoftwareManager(String empName, int empId). Make sure to call their respective super class constructor. Implement toString. Prefix the result of the Employee's toString with "SoftwareManager ". Can you leverage the SoftwareEngineer.toString0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!