Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3. #include <string>
  4. #include <ctime>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. class hotel {
  10. private:
  11. int ID;
  12. string name;
  13. string city;
  14. int numberOfRooms;
  15. int stars;
  16. bool isReserved;
  17. float price;
  18. public:
  19. hotel(int _ID, string _name, string _city, int _numberOfRooms, int _stars, bool _reserved, float _price) {
  20. ID = _ID;
  21. name = _name;
  22. city = _city;
  23. numberOfRooms = _numberOfRooms;
  24. stars = _stars;
  25. isReserved = _reserved;
  26. price = _price;
  27. }
  28. hotel() {
  29. }
  30.  
  31. #pragma region getters
  32. int getID() {
  33. return ID;
  34. }
  35. string getName() {
  36. return name;
  37. }
  38. string getCity() {
  39. return city;
  40. }
  41. int getRooms() {
  42. return numberOfRooms;
  43. }
  44. int getStars() {
  45. return stars;
  46. }
  47. bool getReserve() {
  48. return isReserved;
  49. }
  50. float getPrice() {
  51. return price;
  52. }
  53. #pragma endregion
  54. void setReservation(bool reserved) {
  55. isReserved = reserved;
  56. }
  57. };
  58.  
  59. class customer {
  60. private:
  61. string name;
  62. string lastName;
  63. string IDNum;
  64. int CV;
  65. float money;
  66. hotel instance;
  67. public:
  68. customer(string _name, string _lastname, string _ID, int _CV, float _money) {
  69. name = _name;
  70. lastName = _lastname;
  71. IDNum = _ID;
  72. CV = _CV;
  73. money = _money;
  74. }
  75. customer(hotel _instance) {
  76. instance = _instance;
  77. }
  78.  
  79. #pragma region getters
  80. string getName() {
  81. return name;
  82. }
  83. string getLastname() {
  84. return lastName;
  85. }
  86. string getIDNum() {
  87. return IDNum;
  88. }
  89. int getCV() {
  90. return CV;
  91. }
  92. float getMoney() {
  93. return money;
  94. }
  95. hotel getHotel() {
  96. return instance;
  97. }
  98. #pragma endregion
  99. void setMoney(float mon) {
  100. money = mon;
  101. }
  102. void setReserved(hotel temp) {
  103. instance = temp;
  104. }
  105. };
  106.  
  107. void print(string text) {
  108. cout << text << endl;
  109. }
  110. void reserveARoom(hotel instance, vector<customer> cl) {
  111. string ID;
  112. int CV;
  113. string error;
  114. system("cls");
  115.  
  116. cout << "Enter your card ID number: ";
  117. cin >> ID;
  118. cout << endl;
  119. cout << "Enter your CV code: ";
  120. cin >> CV;
  121. cout << endl;
  122.  
  123. for (auto item : cl)
  124. {
  125. if (item.getIDNum() == ID) {
  126. if (item.getCV() == CV) {
  127. if (instance.getPrice() <= item.getMoney()) {
  128. item.setMoney(item.getMoney() - instance.getPrice());
  129. item.setReserved(instance);
  130. system("cls");
  131. cout << "You successfully reserved a room here are your details" << endl;
  132. cout << "ID: " << instance.getID() << endl;
  133. cout << "Name: " << instance.getName() << endl;
  134. cout << "City: " << instance.getCity() << endl;
  135. cout << "Rooms: " << instance.getRooms() << endl;
  136. cout << "Stars: " << instance.getStars() << endl;
  137. cout << "Price: " << instance.getPrice() << endl;
  138. instance.setReservation(true);
  139. cout << endl << endl;
  140. cout << "Your balance update: " << endl;
  141. cout << "Card holder name: " << item.getName() << " " << item.getLastname() << endl;
  142. cout << "Card ID: " << item.getIDNum() << endl;
  143. cout << "Money on card: $" << item.getMoney() << endl;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. void getHotelsList(vector<hotel> hl, vector<customer>cl) {
  150. system("cls");
  151. for (auto item : hl) {
  152. cout << "ID: " << item.getID() << endl;
  153. cout << "Name: " << item.getName() << endl;
  154. cout << "City: " << item.getCity() << endl;
  155. cout << "Rooms: " << item.getRooms() << endl;
  156. cout << "Stars: " << item.getStars() << endl;
  157. cout << "Price: " << item.getPrice() << endl;
  158. if (item.getReserve())
  159. cout << "RESERVED" << endl;
  160. else
  161. cout << "Available" << endl;
  162. cout << endl <<"*************************************"<< endl;
  163. }
  164. print("Type the ID of room you are interested in: ");
  165. int ID;
  166. cin >> ID;
  167. for (auto item : hl)
  168. {
  169. if (item.getID() == ID) {
  170. reserveARoom(item, cl);
  171. }
  172. }
  173. }
  174. void checkBalance(vector<customer>cl) {
  175. string ID;
  176. int CV;
  177. bool success = false;
  178. cout << "Enter your card ID number: ";
  179. cin >> ID;
  180. cout << endl;
  181. cout << "Enter your CV code: ";
  182. cin >> CV;
  183. cout << endl;
  184.  
  185. for (auto item : cl)
  186. {
  187. if (item.getIDNum() == ID) {
  188. if (item.getCV() == CV) {
  189. cout << "Card holder name: " << item.getName() << " " << item.getLastname() << endl;
  190. cout << "Card ID: " << item.getIDNum() << endl;
  191. cout << "Money on card: $" << item.getMoney() << endl;
  192. success = true;
  193. }
  194. }
  195. }
  196. if(!success)
  197. {
  198. cout << "Failed to find your card" << endl;
  199. }
  200. }
  201.  
  202. void menu(vector<hotel> hl, vector<customer>cl, string error) {
  203. system("cls");
  204. cout << error << endl;
  205. print("1) Check Hotels List");
  206. print("2) Check Customer Balance");
  207. int choice = 0;
  208. cin >> choice;
  209. hotel Hotel;
  210. customer customer(Hotel);
  211. switch (choice)
  212. {
  213. case 1:
  214. getHotelsList(hl, cl);
  215. break;
  216. case 2:
  217. checkBalance(cl);
  218. break;
  219. default:
  220. break;
  221. }
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement