Question

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) /its 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 Employees 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 Employees toString with SoftwareManager . Can you leverage the SoftwareEngineer.toString0?

//*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<Employee> company;

        private void initCompany() {
                company = new ArrayList<Employee>();
                
                company.add(new Executive());
                
                for (int i = 0; i < 3; i++) {
                        company.add(new SoftwareManager());
                        for (int j = 0; j < 2; j++) {
                                company.add(new SoftwareEngineer());
                        }
                }
        }
        
        public void run(int runTime) {
                initCompany();
                
                Random timeGen = new Random();

                currentTime = 0;
                while (currentTime <= runTime) {

                        int scheduledTime = timeGen.nextInt(10) + 1;

                        currentTime += scheduledTime;
                        System.out.println("Current Time: " + currentTime);
                        performWork();
                        
                        System.out.println("\n");
                }
        }

        private void performWork() {
                
                for (Employee emp : company) {
                        if (!emp.work())
                                manageCrisis(emp);
                }

        }
        private void manageCrisis(Employee emp) {
                //TODO Implement CompanySimulator.manageCrisis
        }

        /**
         * @param args
         */
        public static void main(String[] args) {
                CompanySimulator sim = new CompanySimulator();
                sim.run(100);
        }


}
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Sir I have taken your question

I will post solution later as I am not on my desk

Please be patient

Add a comment
Know the answer?
Add Answer to:
//*Manager.java*// public interface Manager { public void handleCrisis(); } _________________________________________________________ /**Employee.java**/ Public abstract class Employee {...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Previous class code: 1) Employee.java ------------------------------------------------------------------------------- /** * */ package main.webapp; /** * @author sargade *...

    Previous class code: 1) Employee.java ------------------------------------------------------------------------------- /** * */ package main.webapp; /** * @author sargade * */ public class Employee { private int empId; private String empName; private Vehicle vehicle; public Double calculatePay() { return null; } /** * @return the empId */ public int getEmpId() { return empId; } /** * @param empId * the empId to set */ public void setEmpId(int empId) { this.empId = empId; } /** * @return the empName */ public String getEmpName() { return...

  • C# Hey I am having trouble implementing additonal function to this assignment: Problem: Implement three IComparer classes on Employee - NameComparer, AgeComparer, and PayComparer - that allow Employee...

    C# Hey I am having trouble implementing additonal function to this assignment: Problem: Implement three IComparer classes on Employee - NameComparer, AgeComparer, and PayComparer - that allow Employees to be compared by the Name, Age, and Pay, respectively. Code: Employee.Core.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Employees { partial class Employee { // Field data. private string empName; private int empID; private float currPay; private int empAge; private string empSSN = ""; private string empBene...

  • HospitalEmployee Inheritance help please. import java.text.NumberFormat; public class HospitalEmployee {    private String empName;    private...

    HospitalEmployee Inheritance help please. import java.text.NumberFormat; public class HospitalEmployee {    private String empName;    private int empNumber;    private double hoursWorked;    private double payRate;       private static int hospitalEmployeeCount = 0;    //-----------------------------------------------------------------    // Sets up this hospital employee with default information.    //-----------------------------------------------------------------    public HospitalEmployee()    { empName = "Chris Smith"; empNumber = 9999; hoursWorked = 0; payRate =0;               hospitalEmployeeCount++;    }       //overloaded constructor.    public HospitalEmployee(String eName,...

  • Please fill in the remaining code necessary and follow the instructions below this is an abstract...

    Please fill in the remaining code necessary and follow the instructions below this is an abstract class; it represents an department in the company. This class cannot be instantiated (objects created), but it serves as the parent for other classes. Department – This class represents a department within the company. 1. Provide the implementation (the body) for the following methods: public int getDepartmentID()) public String getDepartmentName()) public Manager getManager()) 2. Fix the implementation for the following method– substitute “blah” with...

  • In the Employee class, add an implementation for the calculatePension() method declared in the interface. Calculate...

    In the Employee class, add an implementation for the calculatePension() method declared in the interface. Calculate the pension to date as the equivalent of a monthly salary for every year in service. 4) Print the calculated pension for all employees. ************** I added the interface and I implemented the interface with Employee class but, I don't know how can i call the method in main class ************ import java.io.*; public class ManagerTest { public static void main(String[] args) { InputStreamReader...

  • Susceptible.java interface Susceptible { public boolean infect(Disease disease); public void forceInfection(Disease disease); public Disease getCurrentDisease(); public...

    Susceptible.java interface Susceptible { public boolean infect(Disease disease); public void forceInfection(Disease disease); public Disease getCurrentDisease(); public void setImmune(); public boolean isImmune(); public Point getPosition(); } Movable.java interface Movable { public void move(int step); } public class Point { private int xCoordinate; private int yCoordinate; /** * Creates a point at the origin (0,0) and colour set to black */ public Point(){ xCoordinate = 0; yCoordinate = 0; } /** * Creates a new point at a given coordinate and colour...

  • Java Programming Answer 60a, 60b, 60c, 60d. Show code & output. public class Employee { private...

    Java Programming Answer 60a, 60b, 60c, 60d. Show code & output. public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return...

  • Java Do 72a, 72b, 72c, 72d. Code & output required. public class Employee { private int...

    Java Do 72a, 72b, 72c, 72d. Code & output required. public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...

  • JAVA: How do I output all the data included for each employee? I can only get...

    JAVA: How do I output all the data included for each employee? I can only get it to output the name, monthly salary and annual salary, but only from the Employee.java file, not Salesman.java or Executive.java. Employee.java package project1; public class Employee { private String name; private int monthlySalary; public Employee(String name, int monthlySalary) { this.name = name; this.monthlySalary = monthlySalary; } public int getAnnualSalary() { int totalPay = 0; totalPay = 12 * monthlySalary; return totalPay; } public String...

  • How to solve this problem? Consider the following class : public class Store Public final double...

    How to solve this problem? Consider the following class : public class Store Public final double SALES TAX_RATE = 0.063B private String name; public Store(String newName) setName ( newName); public String getName () { return name; public void setName (String newName) { name = newName; public String toString() return "name: “ + name; Write a class encapsulating a web store, which inherits from Store. A web store has the following additional attributes: an Internet Address and the programming language in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT