Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- class hotel {
- private:
- int ID;
- string hotelName;
- string city;
- int rooms;
- int stars;
- float price;
- public:
- hotel(int _ID,string _hotelName, string _city, int _rooms, int _stars, int _price) {
- ID = _ID;
- hotelName = _hotelName;
- city = _city;
- rooms = _rooms;
- stars = _stars;
- price = _price;
- }
- #pragma region getters
- int getID() {
- return ID;
- }
- string getHotelName() {
- return hotelName;
- }
- string getCity() {
- return city;
- }
- int getRooms() {
- return rooms;
- }
- int getStars() {
- return stars;
- }
- float getPrice() {
- return price;
- }
- #pragma endregion
- };
- class wallet {
- private:
- string name;
- string lastName;
- string IDNumber;
- int CVCode;
- float money;
- public:
- wallet(string _name, string _lastName, string _ID, int _CV, float _money) {
- name = _name;
- lastName = _lastName;
- IDNumber = _ID;
- CVCode = _CV;
- money = _money;
- }
- #pragma region getters
- string getName() {
- return name;
- }
- string getLName() {
- return lastName;
- }
- string getID() {
- return IDNumber;
- }
- int getCV() {
- return CVCode;
- }
- float getMoney() {
- return money;
- }
- #pragma endregion
- void setMoney(float _money) {
- money = _money;
- }
- };
- #pragma region declarations
- void menu(vector<hotel>hl, vector<wallet>wl);
- void listHotels(vector<hotel>list, vector<wallet>wl);
- void findHotelByCity(vector<hotel>list, string city, vector<wallet>wl);
- void reserveHotel(vector<hotel> list,hotel instance, vector<wallet> wl);
- wallet validateCard(vector<wallet>list);
- void printWallet(wallet inst);
- void print(string text);
- #pragma endregion
- int main() {
- hotel h1(1, "Ambassador", "Tbilisi", 4, 5, 500);
- hotel h2(2, "Rooms", "Tbilisi", 2, 4, 250);
- hotel h3(3, "Sheraton", "Batumi", 1, 5, 200);
- hotel h4(4, "City Hotel", "Batumi", 2, 3, 150);
- vector<hotel>list;
- list.push_back(h1);
- list.push_back(h2);
- list.push_back(h3);
- list.push_back(h4);
- wallet w1("Toko", "Qurdadze", "77778888", 832, 1000000);
- wallet w2("Vaja", "Vajishvili", "12345678", 123, 9841);
- wallet w3("Shavlegi", "Kuraspetian", "12345688", 123, 100.95);
- vector<wallet>wl;
- wl.push_back(w1);
- wl.push_back(w2);
- wl.push_back(w3);
- menu(list, wl);
- cin.get();
- cin.get();
- }
- void menu(vector<hotel> hl, vector<wallet> wl)
- {
- system("cls");
- print("1) Find a hotel by city");
- print("2) Get all hotels");
- print("3) Check wallet");
- int choice;
- cin >> choice;
- string city;
- switch (choice)
- {
- case 1:
- listHotels(hl, wl);
- break;
- case 2:
- print("Enter name of city you want to find hotel at:");
- cin >> city;
- findHotelByCity(hl, city, wl);
- break;
- case 3:
- break;
- default:
- break;
- }
- }
- void listHotels(vector<hotel> list, vector<wallet>wl)
- {
- system("cls");
- for (auto item : list) {
- print(" ");
- print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
- cout << "ID: " << item.getID() << endl;
- cout << "Name: " << item.getHotelName() << endl;
- cout << "City: " << item.getCity() << endl;
- cout << "Rooms: " << item.getRooms() << endl;
- cout << "Stars: " << item.getStars() << endl;
- cout << "Price: " << item.getPrice() << endl;
- }
- print("Enter ID of hotel you are interested in, if you wish to go back to menu type 420:");
- int ID;
- cin >> ID;
- if (ID != 420) {
- for (auto item : list)
- {
- if (item.getID() == ID) {
- reserveHotel(list, item, wl);
- }
- }
- }
- else
- menu(list, wl);
- }
- void findHotelByCity(vector<hotel> list, string city, vector<wallet> wl)
- {
- system("cls");
- for (auto item : list)
- {
- if (item.getCity() == city) {
- cout << "ID: " << item.getID() << endl;
- cout << "Name: " << item.getHotelName() << endl;
- cout << "City: " << item.getCity() << endl;
- cout << "Rooms: " << item.getRooms() << endl;
- cout << "Stars: " << item.getStars() << endl;
- cout << "Price: " << item.getPrice() << endl;
- }
- }
- print("Enter ID of hotel you are interested in, if you wish to go back to menu type 420:");
- int ID;
- cin >> ID;
- if (ID != 420) {
- for (auto item : list)
- {
- if (item.getID() == ID) {
- reserveHotel(list, item, wl);
- }
- }
- }
- else
- menu(list, wl);
- }
- void reserveHotel(vector<hotel> list,hotel instance, vector<wallet> wl)
- {
- wallet holder = validateCard(wl);
- printWallet(holder);
- cout << endl;
- cout << endl;
- if (instance.getPrice() <= holder.getMoney()) {
- holder.setMoney(holder.getMoney() - instance.getPrice());
- cout << "You successfully reserved a room in " << instance.getHotelName() << endl;
- cout << endl << endl;
- printWallet(holder);
- }
- else {
- cout << "You dont have enough money in your wallet." << endl;
- menu(list, wl);
- }
- }
- wallet validateCard(vector<wallet> list)
- {
- system("cls");
- string ID;
- int CV;
- cout << "Enter ID number of your card: ";
- cin >> ID;
- cout << endl;
- cout << "Enter CV number of your card: ";
- cin >> CV;
- cout << endl;
- for (auto item : list)
- {
- if (item.getID() == ID) {
- if (item.getCV() == CV) {
- return item;
- }
- }
- else {
- cout << "Fail." << endl;
- }
- }
- }
- void printWallet(wallet inst)
- {
- cout << "Holder name: " << inst.getName() << " " << inst.getLName() << endl;
- cout << "ID: " << inst.getID() << endl;
- cout << "Balance: " << inst.getMoney() << endl;
- }
- void print(string text)
- {
- cout << text << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement