Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ALL IN JAVA: Define a class named Employee , which will store data about each employee at a company. Inherit from the Person class (Person.java

ALL IN JAVA:

Define a class named Employee, which will store data about each employee at a company. Inherit from the Person class (Person.java file attached to this assignment). An Employee inherits its name and honorific (title prefixing a person's name, such as Mr., Ms., Mrs., Dr., Sir, Lady, or Lord) from the Person class. In addition, an employee has instance variables to store annual salary (double), year hired (int), and identification number (String).

The Employee class should have 3 constructors:

Parameterized constructor (honorific, name, annualSalary, yearHired, id)

Parameterized constructor (name, annualSalary, yearHired, id )

Copy constructor

Give your class a reasonable complement accessor methods and mutator methods (do not create a setId( ) method, since the id must be unique), as well as an equals( ) and toString( ) method. Write a demo (driver) program to fully test your class definitions.

Now, define another class named Doctor which will be derived (inherit from) the Employee class. The Doctor class should contain two additional instance variables: specialty (a String, such as Pediatrician, Obstetrician, General Practitioner, etc) and office fee (double).

The Doctor should have 2 constructors:

Parameterized constructor (name, annualSalary, yearHired, id, specialty, officeFee)

Copy constructor

Give your class a reasonable set of accessors and mutators, as well as an equals( ) and toString( ) method.

Below is an inheritance diagram in UML (Unified Modeling Language) of the three classes:

image text in transcribed

Person Class Fields honorific name - Methods equals getFullName getHonorific ?getName Person (+ 3 overloads) ?setHonorific setName toString Employee Class person - Fields annualSalary id yearHired - Methods Employee (+ 2 overloads) equals getAnnualSalary ?getid ?getYear:Hired setAnnualsalary ?setYearHired toString Doctor Class Employee - Fields officeFee specialty - Methods Doctor (+ 1 overload) equals getSpecialty setSpecialty ?getOfficeFee ?setOfficeFee toString

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

6. What questions would you suggest should be included?

Answered: 1 week ago