Question: #include #include #include #include #include using namespace std; / / Tour Package class class TourPackage { public: string name; string location; double price; map reservations;

#include
#include
#include
#include
#include
using namespace std;
// Tour Package class
class TourPackage {
public:
string name;
string location;
double price;
map reservations; // date -> number of seats reserved
TourPackage(string name, string location, double price)
: name(name), location(location), price(price){}
void addReservation(string date, int seats){
if (reservations.find(date)!= reservations.end()){
reservations[date]+= seats;
} else {
reservations[date]= seats;
}
}
void deleteReservation(string date, int seats){
if (reservations.find(date)!= reservations.end()){
if (reservations[date]>= seats){
reservations[date]-= seats;
if (reservations[date]==0){
reservations.erase(date);
}
} else {
throw runtime_error("Not enough seats reserved for deletion");
}
} else {
throw runtime_error("No reservation found for deletion");
}
}
bool isSeatsAvailable(string startDate, string endDate, int seats){
for (auto it = reservations.begin(); it != reservations.end(); ++it){
if (it->first >= startDate && it->first <= endDate){
if (it->second >= seats){
return false;
}
}
}
return true;
}
};
// Tourism Company class
class TourismCompany {
public:
vector tourPackages;
void addTourPackage(string name, string location, double price){
tourPackages.push_back(TourPackage(name, location, price));
}
void viewTourPackages(){
for (auto it = tourPackages.begin(); it != tourPackages.end(); ++it){
cout << "Name: "<< it->name <<", Location: "<< it->location <<", Price: "<< it->price << endl;
}
}
void updateTourPackage(string name, string location, double price){
for (auto it = tourPackages.begin(); it != tourPackages.end(); ++it){
if (it->name == name){
it->location = location;
it->price = price;
return;
}
}
throw runtime_error("Tour package not found for update");
}
void deleteTourPackage(string name){
for (auto it = tourPackages.begin(); it != tourPackages.end(); ++it){
if (it->name == name){
tourPackages.erase(it);
return;
}
}
throw runtime_error("Tour package not found for deletion");
}
void addReservation(string packageName, string date, int seats){
for (auto it = tourPackages.begin(); it != tourPackages.end(); ++it){
if (it->name == packageName){
it->addReservation(date, seats);
return;
}
}
throw runtime_error("Tour package not found for reservation");
}
void viewReservations(string packageName){
for (auto it = tourPackages.begin(); it != tourPackages.end(); ++it){
if (it->name == packageName){
for (auto it2= it->reservations.begin(); it2!= it->reservations.end(); ++it2){
cout << "Date: "<< it2->first <<", Seats: "<< it2->second << endl;
}
return;
}
}
throw runtime_error("Tour package not found for viewing reservations");
}
void deleteReservation(string packageName, string date, int seats){
for (auto it = tourPackages.begin(); it != tourPackages.end(); ++it){
if (it->name == packageName){
it->deleteReservation(date, seats);
return;
}
}
throw runtime_error("Tour package not found for reservation deletion");
}
bool isSeatsAvailable(string packageName, string startDate, string endDate, int seats){
for (auto it = tourPackages.begin(); it != tourPackages.end(); ++it){
if (it->name == packageName){
return it->isSeatsAvailable(startDate, endDate, seats);
}
}
throw runtime_error("Tour package '"+ packageName +"' not found for reservation");
}
};
int main(){
TourismCompany company;
while (true){
cout <<"1. Add Tour Package" << endl;
cout <<"2. View Tour Packages" << endl;
cout <<"3. Update Tour Package" << endl;
cout <<"4. Delete Tour Package" << endl;
cout <<"5. Add Reservation" << endl;
cout <<"6. View Reservations" << endl;
cout <<"7. Delete Reservation" << endl;
cout <<"8. Check Seat Availability" << endl; show me the erros

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!