Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this assignment, you must write two classes: Employee.java and Company.java. Inspect their UML diagrams beloww Employee Compan -employeeDatabase: HashMap +getEmployeeDatabase(): HashMap populateEmployeeDatabase(Scanner): void +addEmployee(String,
For this assignment, you must write two classes: Employee.java and Company.java. Inspect their UML diagrams beloww Employee Compan -employeeDatabase: HashMap +getEmployeeDatabase(): HashMap populateEmployeeDatabase(Scanner): void +addEmployee(String, int): void +increaseSalary(int): void -name: String salarv: double id: int emploveeCount: static int +getld(): int +getName): String +getSalary): double +setld(int) +setName(String +setSalary(double) +getEmployeeCount(): static int +print(): void +equals(Emploveel: boolean *Items listed in red are bonus *Note: Constructors are not listed in UML Diagrams For Employee.java 1. 2. Define an Employee's 3 attributes: id, name, salary Define a static int employeeCount inititally set to 0 Increment this variable whenever a new Employee object is created a. i. (Hint: in all of your constructors!) 3. Write accessors for: name, salary, id, and employeeCount 4. 5. a. I should be able to call getEmployeeCount) with the class name (not objects!) Write mutator methods name and salary Write a print method that prints an employee object's information as follows Employee ID: 5 Name: Alice Salary: $50000.0 //Note the $,:, and spacing 6. Define at least two constructors for the Employee class One constructor must be the default constructor (no parameters) In each constructor, initialize salary and name to some default values or the values passed in if you have parameters In each constructor, be sure to increment the employee count and set that Employee object's id number to the current count. Example code to test with a. b. c. d. Employee e1-new Employee(); Employee e2new Employee(); System.out.println(e1.getld(): //prints 0 System.out.println(e2.getld(): //prints 1 System.out.println(Employee.getEmployeeCount()); //prints 2 7. Write an equals method that determines if two Employee objects have the same values for all three attributes. Example code to test with Employee e1 new Employee(810, "Alice", 5); Employee e2 new Employee(810, "Alice", 5); //your constructor may be different System.out.println(e1.equals(e2)); //prints true For this assignment, you must write two classes: Employee.java and Company.java. Inspect their UML diagrams beloww Employee Compan -employeeDatabase: HashMap +getEmployeeDatabase(): HashMap populateEmployeeDatabase(Scanner): void +addEmployee(String, int): void +increaseSalary(int): void -name: String salarv: double id: int emploveeCount: static int +getld(): int +getName): String +getSalary): double +setld(int) +setName(String +setSalary(double) +getEmployeeCount(): static int +print(): void +equals(Emploveel: boolean *Items listed in red are bonus *Note: Constructors are not listed in UML Diagrams For Employee.java 1. 2. Define an Employee's 3 attributes: id, name, salary Define a static int employeeCount inititally set to 0 Increment this variable whenever a new Employee object is created a. i. (Hint: in all of your constructors!) 3. Write accessors for: name, salary, id, and employeeCount 4. 5. a. I should be able to call getEmployeeCount) with the class name (not objects!) Write mutator methods name and salary Write a print method that prints an employee object's information as follows Employee ID: 5 Name: Alice Salary: $50000.0 //Note the $,:, and spacing 6. Define at least two constructors for the Employee class One constructor must be the default constructor (no parameters) In each constructor, initialize salary and name to some default values or the values passed in if you have parameters In each constructor, be sure to increment the employee count and set that Employee object's id number to the current count. Example code to test with a. b. c. d. Employee e1-new Employee(); Employee e2new Employee(); System.out.println(e1.getld(): //prints 0 System.out.println(e2.getld(): //prints 1 System.out.println(Employee.getEmployeeCount()); //prints 2 7. Write an equals method that determines if two Employee objects have the same values for all three attributes. Example code to test with Employee e1 new Employee(810, "Alice", 5); Employee e2 new Employee(810, "Alice", 5); //your constructor may be different System.out.println(e1.equals(e2)); //prints true
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started