Describe this project in 8 to 10 lines.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
#include <algorithm>
#include <iostream>
#include <string>
#include <
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.
Step by step
Solved in 2 steps