Design and implement a set of classes that define the employees
of a hospital.
Start by creating a HospitalEmployee super class, from which three
other classes
will inherit.
The HospitalEmployee class will have the following
components:
• name - a private String instance variable containing the
employee's name
(taken in the object constructor)
• field - a private String instance variable containing the
employee's
field (e.g. cardiology, oncology) (taken in the object
constructor)
• onCall - a private boolean instance variable, set to true if the
employee is
on call, and false otherwise. (initialized as false in the
constructor)
• greeting - a function that takes no parameters, returns nothing,
and prints a
string to standard output with the following format: "Hello, my
name is
[name]. I work in [field]. How can I help you?"
• changeShift - a function that takes no parameters, returns
nothing, and changes
the value of onCall. If onCall is false, changeShift should change
it to
true. Otherwise, onCall should be changed to false.
• isOnCall - a function that takes no parameters and returns the
value of
the boolean onCall.
There will be two classes inheriting from the HospitalEmployee
class- Doctor
and Nurse. These classes will have the following components.
Doctor:
• A constructor that takes two String parameters, the Doctor's name
and the
Doctor's field.
• checkCharts - a function that takes no parameters and returns
nothing. If
the Doctor is on call, it should print out, "Charts have been
checked." Otherwise,
the function should print, "Sorry, it's not my shift."
Nurse:
• A constructor that takes one String parameter, the Nurse's name.
It should
set the variable field to "nursing."
• takeVitals - a function that takes no parameters and returns
nothing. If
the Nurse is on call, it should print out, "Vitals have been
taken." Otherwise,
the function should print, "Sorry, it's not my shift."
Create a driver class, named Hospital, that tests out these
functions.
Create a Doctor object with the name "Jennifer Jackson" and the
field
"pediatrics", as well as a Nurse with the name "Bobbie Blake".
First, call
Bobbie's changeShift function. Then, On separate lines, print out
Jennifer's
greeting, the ouput of her checkCharts function, Bobbie's greeting,
and the output
of his takeVitals function.
Note :
As U didnt mentioned In which language you want me to develop ,I developed in c++.Plz tell me if u need this in Java
Thank you
_____________________
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
class HospitalEmployee
{
private :
string name;
string field;
bool onCall;
public :
HospitalEmployee(string name,string field)
{
this->name=name;
this->field=field;
onCall=false;
}
void greeting()
{
cout<<"Hello, my name is "<<name<<".
I work in "<<field<<". How can I help
you?"<<endl;
}
void changeShift()
{
if(onCall==true)
onCall=false;
else
onCall=true;
}
bool isOnCall()
{
return onCall;
}
};
class Doctor : public HospitalEmployee
{
private :
public :
Doctor(string name,string
field):HospitalEmployee(name,field)
{
}
void checkCharts()
{
if(isOnCall())
{
cout<<"Charts have been
checked."<<endl;
}
else
{
cout<<"Sorry, it's not my
shift."<<endl;
}
}
};
class Nurse:public HospitalEmployee
{
private:
public :
Nurse(string
name):HospitalEmployee(name,"nursing")
{
}
void takeVitals()
{
if(isOnCall())
{
cout<<"Vitals have been
taken."<<endl;
}
else
{
cout<<"Sorry, it's not my shift."<<endl;
}
}
};
int main()
{
Doctor d("Jennifer Jackson","pediatrics");
Nurse n("Bobbie Blake");
n.changeShift();
d.greeting();
d.checkCharts();
n.greeting();
n.takeVitals();
return 0;
}
_______________________________
Output:

______________________Thank You
Below is the implementation of the classes as described:
javaCopy code// HospitalEmployee classclass HospitalEmployee { private String name; private String field; private boolean onCall; public HospitalEmployee(String name, String field) { this.name = name; this.field = field; this.onCall = false;
} public void greeting() {
System.out.println("Hello, my name is " + name + ". I work in " + field + ". How can I help you?");
} public void changeShift() {
onCall = !onCall;
} public boolean isOnCall() { return onCall;
}
}// Doctor classclass Doctor extends HospitalEmployee { public Doctor(String name, String field) { super(name, field);
} public void checkCharts() { if (isOnCall()) {
System.out.println("Charts have been checked.");
} else {
System.out.println("Sorry, it's not my shift.");
}
}
}// Nurse classclass Nurse extends HospitalEmployee { public Nurse(String name) { super(name, "nursing");
} public void takeVitals() { if (isOnCall()) {
System.out.println("Vitals have been taken.");
} else {
System.out.println("Sorry, it's not my shift.");
}
}
}// Driver classpublic class Hospital { public static void main(String[] args) { // Create Doctor and Nurse objects
Doctor jennifer = new Doctor("Jennifer Jackson", "pediatrics"); Nurse bobbie = new Nurse("Bobbie Blake"); // Call Bobbie's changeShift function
bobbie.changeShift(); // Print Jennifer's greeting and the output of her checkCharts function
jennifer.greeting();
jennifer.checkCharts(); // Print Bobbie's greeting and the output of his takeVitals function
bobbie.greeting();
bobbie.takeVitals();
}
}Output:
cssCopy codeHello, my name is Jennifer Jackson. I work in pediatrics. How can I help you? Sorry, it's not my shift. Hello, my name is Bobbie Blake. I work in nursing. How can I help you? Sorry, it's not my shift.
Note: In the provided implementation, the Doctor's and Nurse's classes' functions will print "Sorry, it's not my shift." because we called bobbie.changeShift() to change the onCall status of the Nurse to false. To get different outputs, you can call changeShift again before calling jennifer.checkCharts() and bobbie.takeVitals().
Design and implement a set of classes that define the employees of a hospital. Start by...
Design and implement a set of classes that define the employees of a hospital: doctor, nurse, administrator, surgeon, receptionist, janitor, and so on. Include methods in each class that are named according to the services provided by that person and that print an appropriate message. Create a driver class to instantiate and exercise several of the classes.
HW question: Write an iterative method printHighEarners() to print all high earner employees. Method printHighEarners()is in the class LinkedList. LinkedList has private instance variable list of Node type. Class Node is private inner class inside of class LinkedList, and has public instance variables: data and next of Employee and Node type, respectively. In addition, class Node has constructor and toString method. See LinkedList class bellow on the right. Class Employee has getters for all data, method String toString() that returns...
A Java Program Purpose: Work with Abstract classes. Purpose: Abstract classes are import because they ensure than any children which inherit from it must implement certain methods. This is done to enforce consistency across many different classes. Problem: Implement a class called Student. This class needs to be abstract and should contain a String for the name, and a String for the major (and they should be private). The class must have a constructor to set the name and major....
JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...
Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will have four instance variables: • An instance variable called “year” which will be of type int • An instance variable called “month” which will be of type int • An instance variable called “day” which will be of type int • An instance variable called “description” which will be of type String The “Appointment” class must also implement the following methods: • A getter...
About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which has private data members for name, age, gender, and height. You MUST use this pointer when any of the member functions are using the member variables. Implement a constructor that initializes the strings with an empty string, characters with a null character and the numbers with zero. Create getters and setters for each member variable. Ensure that you identify correctly which member functions should...
Java Create four classes: 1. An Animal class that acts as a superclass for Dog and Bird 2. A Bird class that is a descendant of Animal 3. A Dog class that is a descendant of Animal 4. A “driver” class named driver that instantiates an Animal, a Dog, and a Bird object. The Animal class has: · one instance variable, a private String variable named name · a single constructor that takes one argument, a String, used to set...
In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...
Please answer the following question with Java Modify the Employee and ProductionWorker classes provided below so they throw exceptions when the following errors occur. - The Employee class should throw an exception named InvalidEmployeeNumber when it receives an employee number that is less than 0 or greater than 9999. - The ProductionWorker class should throw an exception named InvalidShift when it receives an invalid shift. - The ProductionWorker class should thrown anexception named InvalidPayRate when it receives a negative number...
use
intellij idea
main java
wp the professor. Please make sure to only implement what is asked for. You may not add any instance variables to any class, though you may create local variables inside of a method to accomplish its task. No other methods should be created other than the ones listed here. Step 1 Develop the following interface: Interface Name: Queue Interface<T> Access Modifier: public Methods Name: isEmpty Access modifier: public Parameters: none Return type: boolean Name: dequeue...