Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use JAVA .thanks Implement the following classes hierarchy represented using the following UML diagram: Employee # name: String #age: int #salary: double + Employee() +

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Use JAVA .thanks

Implement the following classes hierarchy represented using the following UML diagram: Employee # name: String #age: int #salary: double + Employee() + Employee(name: String, age: int, salary: double) + setName(name: String): void + getName(): String + setAge(age: int): void + getAge(): int + set Salary(salary: double):void + getSalary(): double + equals(o: Object): boolean + toString(): String 1 1n Manager - bonus: double + team: Staff [] + level: int + Manager + Manager(name: String, age: int, salary: double, bonus: double, level: int) + addStaff(staff: Staff): void + setBonus(bonus: double): void + getBonus(): double + getSalary(): double + equals(o:object): boolean + toString(): String Staff position: String + Staff + Staff (name: String, age: int, salary: double, position: String) + getPosition(); String + setPosition(position:String):void Part Timer - payRate: double + workedHours: int + Part Timer + Part Timer (name: String, age: int, workedHours: int, payRate: double) + getSalary(): double + getPayRate(): double + setPayRate(payRate: double): void + equals(o: Object): boolean + toString(): String Note the following: - In the Employee class: 1. The no-arg constructor must read the name, age and salary from the user using input dialog boxes 2. The setName method must make sure that the passed name consists of exactly two segments (words). If not it should not set the name. 3. The toString method must be overridden such that it returns a String that consists of: Name: ..... Age:..... Salary: ....... 4. The equals method must be overridden such that two employees are equal if they have the same salary - In the Manager class: 1. The team array should be initialized with 0 elements. 2. The no-arg constructor must invoke the no-arg of the super class to read name, age and salary, and then read the bonus and the level using input dialog boxes. 3. The toString method must be overridden such that it returns a String that contains the name, age, and salary as in the Employee class, and add on the next line the level, then print the staff names on the next lines as follows: Name: ..... Age:..... Salary: ....... Manager Level: .... Staff names: 4. The getSalary method must be overridden such that it returns the salary plus the bonus. 5. The equals method must overridden such that it returns true if the two managers have the same salary and level. Note that you should invoke the equals method of the super class to compare salaries. - In the Staff class: 1. The no-arg constructor must invoke the no-arg of the super class to read name, age and salary, and then read the position using input dialog boxes. - In the Part Timer class: 1. The getSalary method must be overridden such that it returns the salary as the pay Rate multiplied by the worked Hours. 2. The equals method must be overridden such that it returns true if the two part-timers have the same payRate. 3. The toString method must be overridden such that it returns a String that contains the name, age, and salary as in the Employee class, and add on the next line the pay rate and the worked hours. In your main class: 1. Create a method called printEmployee Details with the following header: public static void print Employee Details (Employee I e) The method should ask the user to enter the employee name using an input dialog box, then find the employee with the entered name in the array of employees and print his/her details by invoking the toString method. 2. In your main method: - Ask the user about the number of employees and create an array with the entered number as a size. - For the actual type of each employee, you should ask the user to choose the type of employee to be created, using an input dialog box as follows: X Input ? What type of employee do you want to create? 1.Employee 2.Manager 3. Staff 4.Part Timer OK Cancel Then the data fields should be initialized with values taken from the user using input dialog boxes by invoking the no-arg constructor of the selected type. -Test the printEmployee Details method by invoking it and passing the formed table. Please note the following modifications/additions to assignment 6: First modifications are in class Part Timer. Second modification is in the last line of the assignment. Please check the attached figures. Part Timer - payRate: double + workedHours: int + Part Timer + Part Timer (name: String, age: int, workedHours: int, payRate: double) + getSalary(): double + getPayRate(): double + setPayRate(payRate: double): void + equals(o: Object): boolean + toString(): String no-arg constructor must invoke the no-arg constructor of the super class and read the payRate and workedHours from the use in input dialog boxes. Please correct the header of this constructor to take the salary and position as paremeters as well. It should pass all parameter that corresponds to inherited data fields to the super class constuctor and initialize the payRate and workedHours with the corrsponding passed parameters. Then the data fields should be initialized with values taken from the user using input dialog boxes by invoking the no-arg constructor of the selected type. -Test the printEmployee Details method by invoking it and passing the formed table: array

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

ISBN: 0130913677, 978-0130913678

More Books

Students also viewed these Databases questions