Describe this project in 8 to 10 lines.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Hotel {
public:
string name;
int roomAvl;
string location;
int rating;
int pricePr;
};

class User : public Hotel {
public:
string uname;
int uId;
int cost;
};

bool sortByIsb(Hotel& A, Hotel& B)
{
return A.name > B.name;
}

bool sortByr(Hotel& A, Hotel& B)
{
return A.rating > B.rating;
}

bool sortByRoomAvalable(Hotel& A,
Hotel& B)
{
return A.roomAvl < B.roomAvl;
}

void PrintHotelData(vector<Hotel> hotels)
{
cout << "PRINT HOTELS DATA:" << endl;
cout << "HotelName"
<< " "
<< "Room Avalable"
<< " "
<< "Location"
<< " "
<< "Rating"
<< " "
<< "PricePer Room:" << endl;

for (int i = 0; i < 3; i++) {
cout << hotels[i].name
<< " "
<< hotels[i].roomAvl
<< " "
<< hotels[i].location
<< " "
<< hotels[i].rating
<< " "
<< hotels[i].pricePr
<< endl;
}
cout << endl;
}

void SortHotelByName(vector<Hotel> hotels)
{
cout << "SORT BY NAME:" << endl;

std::sort(hotels.begin(), hotels.end(),
sortByIsb);

for (int i = 0; i < hotels.size(); i++) {
cout << hotels[i].name << " "
<< hotels[i].roomAvl << " "
<< hotels[i].location << " "
<< hotels[i].rating << " "
<< " " << hotels[i].pricePr
<< endl;
}
cout << endl;
}

void SortHotelByRating(vector<Hotel> hotels)
{
cout << "SORT BY A RATING:" << endl;

std::sort(hotels.begin(),
hotels.end(), sortByr);

for (int i = 0; i < hotels.size(); i++) {
cout << hotels[i].name << " "
<< hotels[i].roomAvl << " "
<< hotels[i].location << " "
<< hotels[i].rating << " "
<< " " << hotels[i].pricePr
<< endl;
}
cout << endl;
}

void PrintHotelBycity(string s,
vector<Hotel> hotels)
{
cout << "HOTELS FOR " << s
<< " LOCATION IS:"
<< endl;
for (int i = 0; i < hotels.size(); i++) {

if (hotels[i].location == s) {

cout << hotels[i].name << " "
<< hotels[i].roomAvl << " "
<< hotels[i].location << " "
<< hotels[i].rating << " "
<< " " << hotels[i].pricePr
<< endl;
}
}
cout << endl;
}

void SortByRoomAvailable(vector<Hotel> hotels)
{
cout << "SORT BY ROOM AVAILABLE:" << endl;

std::sort(hotels.begin(), hotels.end(),
sortByRoomAvalable);

for (int i = hotels.size() - 1; i >= 0; i--) {

cout << hotels[i].name << " "
<< hotels[i].roomAvl << " "
<< hotels[i].location << " "
<< hotels[i].rating << " "
<< " " << hotels[i].pricePr
<< endl;
}
cout << endl;
}

void PrintUserData(string userName[],
int userId[],
int bookingCost[],
vector<Hotel> hotels)
{

vector<User> user;
User u;

for (int i = 0; i < 3; i++) {
u.uname = userName[i];
u.uId = userId[i];
u.cost = bookingCost[i];
user.push_back(u);
}

cout << "PRINT USER BOOKING DATA:"
<< endl;
cout << "UserName"
<< " "
<< "UserID"
<< " "
<< "HotelName"
<< " "
<< "BookingCost" << endl;

for (int i = 0; i < user.size(); i++) {
cout << user[i].uname
<< " "
<< user[i].uId
<< " "
<< hotels[i].name
<< " "
<< user[i].cost
<< endl;
}
}

void HotelManagement(string userName[],
int userId[],
string hotelName[],
int bookingCost[],
int rooms[],
string locations[],
int ratings[],
int prices[])
{
vector<Hotel> hotels;

Hotel h;

for (int i = 0; i < 3; i++) {
h.name = hotelName[i];
h.roomAvl = rooms[i];
h.location = locations[i];
h.rating = ratings[i];
h.pricePr = prices[i];
hotels.push_back(h);
}
cout << endl;

PrintHotelData(hotels);
SortHotelByName(hotels);
SortHotelByRating(hotels);
PrintHotelBycity("Islamabad",
hotels);
SortByRoomAvailable(hotels);
PrintUserData(userName,
userId,
bookingCost,
hotels);
}

int main()
{

string userName[] = { "U1", "U2", "U3" };
int userId[] = { 2, 3, 4 };
string hotelName[] = { "H1", "H2", "H3" };
int bookingCost[] = { 1000, 1200, 1100 };
int rooms[] = { 4, 5, 6 };
string locations[] = { "Islamabad",
"Islamabad",
"Murree" };
int ratings[] = { 5, 5, 3 };
int prices[] = { 100, 200, 100 };

HotelManagement(userName, userId,
hotelName, bookingCost,
rooms, locations,
ratings, prices);

return 0;
}

Describe this project in 8 to 10 lines.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education