Answered step by step
Verified Expert Solution
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:
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
shiftHours of type int which represents hours worked in a shift, where is not working and is a full day.
Constructor:
A parameterized constructor to initialize the instance variables using setters to validate and set the values within defined bounds.
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 to for experience years and to for shift hours. If an invalid value is provided, the respective level is set to
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 rechargeExperienceYearsint amountOverridden: 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
a public method calculateSalary: engages the calculation of the doctor's salary based on the workload efficiency and experience years.
Salarytimes Workload Efficiencytimes Experience Years
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: shiftHours: 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
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