You are said to store data of Hospitals in a city. For that purpose, you are asked to develop a structure of maxHeap using these structures in c++. You have to submit Hospital. h file only
class Hospital
{
string HospitalName;
string Address;
string HospitalID;
public:
Hospital();
Hospital(string ,string ,string);
Hospital(string HospitalID); // conversion Constructor
string getHospitalName()const;
string getHospitalId()const;
string getAddress()const;
void setHospitalName(string);
void setHospitalId(string);
void setAddress(string);
// Relational operators with respect to Hospital Id
bool operator<(Hospital)const;
bool operator<=(Hospital)const;
bool operator>(Hospital)const;
bool operator>=(Hospital)const;
bool operator==(Hospital)const;
bool operator!=(Hospital)const;
// output stream operator
friend ostream& operator<<(ostream&, const Hospital& ref); s
};
ostream& operator<<(ostream&, const Hospital& ref);
class MaxHeap
{
public:
class Node
{
public:
Hospital data;
Node* left;
Node* right;
};
private:
Node* root;
public:
MaxHeap();
bool Insert(Hospital);
bool Remove(Hospital);
bool Replace(Hospital old_Hos, Hospital new_Hos);
Hospital* getHeapArray()const;
~MaxHeap();
};
#include <iostream>
#include"Hostpital.h"
using namespace std;
int main()
{
MaxHeap a;
a.Insert(Hospital("Meo", "Lahore", "HL1"));
a.Insert(Hospital("Jinnah", "Lahore", "HL2"));
a.Insert(Hospital("Civil", "Lahore", "HL3")); a.Insert(Hospital("Cardialogy", "Lahore", "HL4")); a.Insert(Hospital("Nishtar", "Multan", "HM1"));
a.Insert(Hospital("Punjab Medical", "Faisalabad", "HF1")); a.Insert(Hospital("Allied", "Faisalabad", "HF2"));
Hospital* ptr= a.getHeapArray();
for (int i = 0; i < 7; i++)
{
cout << i[ptr]<<endl;
}
delete[] ptr;
a.Remove(Hospital("HF2"));
a.Replace(Hospital("HL4"), Hospital("THQ", "Burewala", "HB1"));
ptr = a.getHeapArray();
for (int i = 0; i < 6; i++)
{
cout << i[ptr] << endl;
}
delete[] ptr;
return 0;
}
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Write a C++ program to do the following tasks: Create a Class called Vector with the following private data members: X (float type) Y (float type) Create the constructor methods for: No input arguments (default values: X=0, Y=0) One input argument (default values: Y=0) Two input arguments Create set and get class methods (class functions) for each member where: The get method will return and print the value of the data member The set method will change the value of the data member Create a magnitude class method that performs the following task: M=X2+Y2 Method should return the value of M Create a direction class method that that performs the following task: D-tan-1YX Method should return the value of D In the main function create an instance of the Vector class: with no input arguments with X=5 with X=3 and Y=5. For this instance of the class, show the functionalities of set, get, magnitude, and direction methods. Note: Show the content of different files in a different tablearrow_forwardPlease examine the C++ code and make corrections please. ##include<bits / stdc++.h> using namespace std; //employee class class Employee { private: //fields string name, address, phone; double payRate; public: //cosntructors Employee() {} Employee(string n, string a, double p, string ph) { name = n; address = a; payRate = p; phone = p; } //accessors string getName() { return name; } string getAddress() { return address; } string getPhone() { return phone; } double getPayRate() { return payRate; } //setters void setName(string n) { name = n; } void setAddress(string a) { address = a; } void setPhone(string ph) { phone = ph; } void setPayRate(double pr) { payRate = pr; } }; //employee directory class class EmployeeDirectory { private: //all employees are added into this vector vector<Employee> employees; public:…arrow_forwardOOP (C++) , give code and compile it.arrow_forward
- Write a program using the C ++ language and its affiliate OOP to make a simple mathematical calculator. This program must contain the following topics :1- inheritance. 2- operator overloading.3- Vector. 4- Friend function and friend class. Write code with the mentioned idea and the code comments with execution.arrow_forwardSubmit code in C++ CODE with comments and output screenshot is must to get Upvote. Thanksarrow_forwardMember Lengths Members Sections Load Diagram 4000 mm 6000 mm 5000 mm 100.000 N 4000 mm 6000 mm 5000 mm 70.00 EN 4000 mm 6000 mm 5000 mm Rect 0.40x0.40 Rect 0.30x0.20 Rect 0.40x0.25 Rect 0.50x0.50 ww 000c ww 000v ww 000 ww 000r ww 000s ww 00 ww 000 ww 000c ww 000f ww 000arrow_forward
- Should be implement in C++ with commentsarrow_forwardin c++, write a class named Airline with the following properties and functionality.* Airline-owned fleet (variable that holds the number of aircraft in the fleet named Fleet)* A structure that holds all airline flights (a suitable container must be used from STL)* A structure that holds flights and reservations (an appropriate container must be used from STL)O reservations must be questionable with flight numbers* Creating a flight reservation* Change your flight reservation* Cancel a flight reservation* Total number of passengers per year* Total number of flights per year* Annual total flight hours• Annual total travelled the road* Adding new flightsO flight numbers must be a randomly generated 4-digit integerthese flight numbers are unique to each flight, two flights cannot have the same numberarrow_forwardWrite a c++ create a class with a static member item so that whenever a new object is created the total number of objects of the class can be reported.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education