C++ 1. Create a class template called PatientRecord which includes following thr
ID: 3717180 • Letter: C
Question
C++
1. Create a class template called PatientRecord which includes following three data members:
ItemType lastName;
ItemType firstName;
int priorityNumber;
Please include default and none-default constructors, set and get functions, and overload all the necessary operators.
2. Write a program that
a) Declare an array, called patient, of 12 PatientRecords<string> with lastName and firstName of each PatientRecord initialized.
b) Using rand() to assign a random priority number from 1 to 10 to each PatientRecord in the array..
c) Place each PatientRecord of the array into an instance of class template PQueue with ItemType being string, called patientQueue.
d) Display the first and the last names of the patients who have the highest priority numbers.
Explanation / Answer
If you post more than 1 question, as per chegg guidelines I have to solve only first question.
Ques 1.
#include<iostream>
using namespace std;
class PatientRecord{
ItemType lastName;
ItemType firstName;
int priorityNumber;
public:
// default constructor
PatientRecord()
{
this->firstName = NULL;
this->lastName = NULL;
this->priorityNumber = 0;
}
// constructor
PatientRecord(ItemType firstName, ItemType lastName, int priorityNumber)
{
this->firstName = firstName;
this->lastName = lastName;
this->priorityNumber = priorityNumber;
}
// setter methods
void setFirstName(ItemType firstName)
{
this->firstName = firstName;
}
void setLastName(ItemType lastName)
{
this->lastName = lastName;
}
void setPriorityNumber(int priorityNumber)
{
this->priorityNumber = priorityNumber;
}
// getter methods
ItemType getFirstName()
{
return this->firstName;
}
ItemType getLastName()
{
return this->lastName;
}
int getPriorityNumber()
{
return this->priorityNumber;
}
};
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.