Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <iostream>
- #include <string>
- #include <ctime>
- #include <vector>
- using namespace std;
- class hotel {
- private:
- int ID;
- string name;
- string city;
- int numberOfRooms;
- int stars;
- bool isReserved;
- float price;
- public:
- hotel(int _ID, string _name, string _city, int _numberOfRooms, int _stars, bool _reserved, float _price) {
- ID = _ID;
- name = _name;
- city = _city;
- numberOfRooms = _numberOfRooms;
- stars = _stars;
- isReserved = _reserved;
- price = _price;
- }
- hotel() {
- }
- #pragma region getters
- int getID() {
- return ID;
- }
- string getName() {
- return name;
- }
- string getCity() {
- return city;
- }
- int getRooms() {
- return numberOfRooms;
- }
- int getStars() {
- return stars;
- }
- bool getReserve() {
- return isReserved;
- }
- float getPrice() {
- return price;
- }
- #pragma endregion
- void setReservation(bool reserved) {
- isReserved = reserved;
- }
- };
- class customer {
- private:
- string name;
- string lastName;
- string IDNum;
- int CV;
- float money;
- hotel instance;
- public:
- customer(string _name, string _lastname, string _ID, int _CV, float _money) {
- name = _name;
- lastName = _lastname;
- IDNum = _ID;
- CV = _CV;
- money = _money;
- }
- customer(hotel _instance) {
- instance = _instance;
- }
- #pragma region getters
- string getName() {
- return name;
- }
- string getLastname() {
- return lastName;
- }
- string getIDNum() {
- return IDNum;
- }
- int getCV() {
- return CV;
- }
- float getMoney() {
- return money;
- }
- hotel getHotel() {
- return instance;
- }
- #pragma endregion
- void setMoney(float mon) {
- money = mon;
- }
- void setReserved(hotel temp) {
- instance = temp;
- }
- };
- void print(string text) {
- cout << text << endl;
- }
- void reserveARoom(hotel instance, vector<customer> cl) {
- string ID;
- int CV;
- string error;
- system("cls");
- cout << "Enter your card ID number: ";
- cin >> ID;
- cout << endl;
- cout << "Enter your CV code: ";
- cin >> CV;
- cout << endl;
- for (auto item : cl)
- {
- if (item.getIDNum() == ID) {
- if (item.getCV() == CV) {
- if (instance.getPrice() <= item.getMoney()) {
- item.setMoney(item.getMoney() - instance.getPrice());
- item.setReserved(instance);
- system("cls");
- cout << "You successfully reserved a room here are your details" << endl;
- cout << "ID: " << instance.getID() << endl;
- cout << "Name: " << instance.getName() << endl;
- cout << "City: " << instance.getCity() << endl;
- cout << "Rooms: " << instance.getRooms() << endl;
- cout << "Stars: " << instance.getStars() << endl;
- cout << "Price: " << instance.getPrice() << endl;
- instance.setReservation(true);
- cout << endl << endl;
- cout << "Your balance update: " << endl;
- cout << "Card holder name: " << item.getName() << " " << item.getLastname() << endl;
- cout << "Card ID: " << item.getIDNum() << endl;
- cout << "Money on card: $" << item.getMoney() << endl;
- }
- }
- }
- }
- }
- void getHotelsList(vector<hotel> hl, vector<customer>cl) {
- system("cls");
- for (auto item : hl) {
- cout << "ID: " << item.getID() << endl;
- cout << "Name: " << item.getName() << endl;
- cout << "City: " << item.getCity() << endl;
- cout << "Rooms: " << item.getRooms() << endl;
- cout << "Stars: " << item.getStars() << endl;
- cout << "Price: " << item.getPrice() << endl;
- if (item.getReserve())
- cout << "RESERVED" << endl;
- else
- cout << "Available" << endl;
- cout << endl <<"*************************************"<< endl;
- }
- print("Type the ID of room you are interested in: ");
- int ID;
- cin >> ID;
- for (auto item : hl)
- {
- if (item.getID() == ID) {
- reserveARoom(item, cl);
- }
- }
- }
- void checkBalance(vector<customer>cl) {
- string ID;
- int CV;
- bool success = false;
- cout << "Enter your card ID number: ";
- cin >> ID;
- cout << endl;
- cout << "Enter your CV code: ";
- cin >> CV;
- cout << endl;
- for (auto item : cl)
- {
- if (item.getIDNum() == ID) {
- if (item.getCV() == CV) {
- cout << "Card holder name: " << item.getName() << " " << item.getLastname() << endl;
- cout << "Card ID: " << item.getIDNum() << endl;
- cout << "Money on card: $" << item.getMoney() << endl;
- success = true;
- }
- }
- }
- if(!success)
- {
- cout << "Failed to find your card" << endl;
- }
- }
- void menu(vector<hotel> hl, vector<customer>cl, string error) {
- system("cls");
- cout << error << endl;
- print("1) Check Hotels List");
- print("2) Check Customer Balance");
- int choice = 0;
- cin >> choice;
- hotel Hotel;
- customer customer(Hotel);
- switch (choice)
- {
- case 1:
- getHotelsList(hl, cl);
- break;
- case 2:
- checkBalance(cl);
- break;
- default:
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement