Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a class hierarchy to model various types of medical staff members, incorporating shared properties and behaviors characteristic of hospital personnel. A . Write a

Implement a class hierarchy to model various types of medical staff members, incorporating shared properties and behaviors characteristic of hospital personnel.
A. Write a class named MedicalStaff which contains the following:
1. Three instance variables:
A protected instance variable staffName of type String.
Two private instance variables:
experienceYears of type int which represents years of experience, starting from 0.
shiftHours of type int which represents hours worked in a shift, where 0 is not working and 24 is a full day.
2. Constructor:
A parameterized constructor to initialize the instance variables using setters to validate and set the values within defined bounds.
3. Methods:
Two public methods getExperienceYears() and getShiftHours() to access the instance variables.
Two public methods setExperienceYears and setShiftHours to set the experience years and shift hours with validation to ensure values remain within the range of 0 to 50 for experience years and 0 to 24 for shift hours. If an invalid value is provided, the respective level is set to 0.
A public method calculateWorkloadEfficiency() that calculates the workload based on the shift hours worked and the experience years. The workload efficiency is calculated as (shiftHours * experienceYears).
A public method rechargeExperienceYears (int amount) that increases the staff's experienceYears by the specified amount.
B. Write a class named Doctor which inherits from class MedicalStaff. The class Doctor contains the following:
A constructor with parameters to initialize staffName, experienceYears, and shiftHours.
A public method rechargeExperienceYears(int amount)(Overridden): Doctors gain more experience from work compared to other medical staff. Consequently, this method will increase the doctor's experience by the specified amount multiplied by 1.5.
a public method calculateSalary(): engages the calculation of the doctor's salary based on the workload efficiency and experience years.
Salary=500\times (Workload Efficiency+1)\times (Experience Years+1)
Hint: Use setter methods in all cases where values are stored to ensure each value meets validation criteria.
C. Write a class named HospitalDemo to manage interactions with medical staff members as follows:
Instantiate two Doctor objects, initializing them with your chosen values, for example: name: "Dr. Smith", experienceYears: 10, shiftHours: 8 for the first doctor, and appropriate values for the second.
Simulate various interactions such as calculateWorkloadEfficiency(), rechargeExperienceYears (int amount), and calculateSalary() with both objects.
Display the current status of each Doctor object to reflect changes in experience years, shift hours.
Compare the first Doctor object to the second Doctor object. If they are considered equal (based on experience years and shift hours), print "Exactly the same"; otherwise, print "Noticeably Different". IN JAVA

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

Students also viewed these Databases questions

Question

How does teacher immediacy affect learning?

Answered: 1 week ago