Question: Can somebody solve the following problem using java Employee Boss All your classes should be in a single .java file. Write a program that stores
Can somebody solve the following problem using java
Employee Boss All your classes should be in a single .java file. Write a program that stores employee information. You will have 3 classes: Employee, Address and Driver Employee class (All variables are private) fName String lName String boss Employee //points to an Employee object. addr Address //points to an Address object count integer //stores the total number of employees Since all the variables are private, you must use getter and setter methods to get access to these variables. The count variable should be incremented through the anonymous instance block This class will have 3 constructors o Constructor 1: Takes 2 arguments: fname, and lname o Constructor 2: Take 3 arguments: fName, lName and boss o Constructor 3: Takes 4 arguments: fName, lName, boss and addr o Note: Make sure that constructor 2 refers to constructor 1 to populate fName and lName o Make sure that constructor 3 refers to constructor 2 to populate fName, lName and boss It is possible for an employee to not have a boss, which means the boss is set to null. Address class (All variables are private) city String state String Since all the variables are private, you must use getter and setter methods to get access to these variables. This class will have 1 constructor which takes the city and state Driver class (All variables are local) Grab input from the user to create 3 Employee objects. Use the following variables to point to the objects: emp1, emp2, emp3 (do not use arrays, vectors or lists) Grabbing name: Grab the first name and last name as a single input separated by a space. Separate the name into first name and last name Grabbing address: Grab the city and state as a single input separated by a comma. Separate the address into city and state
1st object Use the 1st constructor Use setter methods to assign values to other variables Set the boss to null 2nd object Use the 2nd constructor Use setter methods to assign values to other variables Set the boss to the first employee 3rd object Use the 3rd constructor Set the boss to the 2nd employee The count variable in the Employee class should only be incremented through the anonymous instance block every time an employee is created. After all the employees are created, display all the information for each employee using the appropriate getter methods. NOTE: You should call other methods from within main (helper methods) to ensure that your main method is not too big. Your main method should not contain more than 15 lines of code. What to turn in: Single .java file Make sure your program compiles and runs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
