Could someone please answer this C++ question? Your local hospital has asked you
ID: 3786869 • Letter: C
Question
Could someone please answer this C++ question?
Your local hospital has asked you to develop a program that will manage health care records. Implement the following 2 classes and write a program that tests these classes:
Patient class has private data members firstName, lastName, patientID, billTotal.
Doctor class has private data members firstName, lastName, specialization.
For each class implement at least one constructor. The constructor should initialize at least one of the private data members. For each class implement accessor member functions for all private data members. For the Patient class, implement a mutator member function that sets the billTotal data member to an updated total if a charge has been made.
To test a class you would write a program that uses the constructor to construct an object of the class type and then calls all mutator member functions. Write a program that tests your Patient and Doctor classes. You must thoroughly comment your code by providing a comment for each line of code. Apply troubleshooting and testing strategies to ensure your code compiles, runs, and provides accurate results.
Explanation / Answer
Code:
#include<iostream>
using namespace std;
class Patient
{
private:
string firstName, lastName, patientID, billTotal;
public:
Patient(string fname,string lname,string pid,string bt)
{
firstName=fname;
lastName=lname;
patientID=pid;
billTotal =bt;
}
string getfname()
{
return firstName;
}
string getlname()
{
return lastName;
}
string getpid()
{
return patientID;
}
string getbillTotal()
{
return billTotal;
}
void setbill(string val)
{
billTotal =val;
}
};
class Doctor
{
private:
string firstName, lastName, specialization;
public:
Doctor(string fname,string lname,string sp)
{
firstName= fname;
lastName=lname;
specialization=sp;
}
string getfname()
{
return firstName;
}
string getlname()
{
return lastName;
}
string getsp()
{
return specialization;
}
};
int main()
{
Patient* p = new Patient("ankit","sharma","1","12");
Doctor* d = new Doctor("amit","sharma","dentist");
}