Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. class hotel {
  8. private:
  9. int ID;
  10. string hotelName;
  11. string city;
  12. int rooms;
  13. int stars;
  14. float price;
  15. public:
  16. hotel(int _ID,string _hotelName, string _city, int _rooms, int _stars, int _price) {
  17. ID = _ID;
  18. hotelName = _hotelName;
  19. city = _city;
  20. rooms = _rooms;
  21. stars = _stars;
  22. price = _price;
  23. }
  24.  
  25. #pragma region getters
  26. int getID() {
  27. return ID;
  28. }
  29. string getHotelName() {
  30. return hotelName;
  31. }
  32. string getCity() {
  33. return city;
  34. }
  35. int getRooms() {
  36. return rooms;
  37. }
  38.  
  39. int getStars() {
  40. return stars;
  41. }
  42. float getPrice() {
  43. return price;
  44. }
  45. #pragma endregion
  46.  
  47. };
  48.  
  49. class wallet {
  50. private:
  51. string name;
  52. string lastName;
  53. string IDNumber;
  54. int CVCode;
  55. float money;
  56. public:
  57. wallet(string _name, string _lastName, string _ID, int _CV, float _money) {
  58. name = _name;
  59. lastName = _lastName;
  60. IDNumber = _ID;
  61. CVCode = _CV;
  62. money = _money;
  63. }
  64. #pragma region getters
  65. string getName() {
  66. return name;
  67. }
  68. string getLName() {
  69. return lastName;
  70. }
  71. string getID() {
  72. return IDNumber;
  73. }
  74. int getCV() {
  75. return CVCode;
  76. }
  77. float getMoney() {
  78. return money;
  79. }
  80. #pragma endregion
  81. void setMoney(float _money) {
  82. money = _money;
  83. }
  84. };
  85.  
  86. #pragma region declarations
  87. void menu(vector<hotel>hl, vector<wallet>wl);
  88. void listHotels(vector<hotel>list, vector<wallet>wl);
  89. void findHotelByCity(vector<hotel>list, string city, vector<wallet>wl);
  90. void reserveHotel(vector<hotel> list,hotel instance, vector<wallet> wl);
  91. wallet validateCard(vector<wallet>list);
  92. void printWallet(wallet inst);
  93. void print(string text);
  94. #pragma endregion
  95.  
  96. int main() {
  97.  
  98. hotel h1(1, "Ambassador", "Tbilisi", 4, 5, 500);
  99. hotel h2(2, "Rooms", "Tbilisi", 2, 4, 250);
  100. hotel h3(3, "Sheraton", "Batumi", 1, 5, 200);
  101. hotel h4(4, "City Hotel", "Batumi", 2, 3, 150);
  102.  
  103.  
  104. vector<hotel>list;
  105. list.push_back(h1);
  106. list.push_back(h2);
  107. list.push_back(h3);
  108. list.push_back(h4);
  109.  
  110. wallet w1("Toko", "Qurdadze", "77778888", 832, 1000000);
  111. wallet w2("Vaja", "Vajishvili", "12345678", 123, 9841);
  112. wallet w3("Shavlegi", "Kuraspetian", "12345688", 123, 100.95);
  113.  
  114. vector<wallet>wl;
  115. wl.push_back(w1);
  116. wl.push_back(w2);
  117. wl.push_back(w3);
  118.  
  119. menu(list, wl);
  120.  
  121. cin.get();
  122. cin.get();
  123. }
  124.  
  125. void menu(vector<hotel> hl, vector<wallet> wl)
  126. {
  127. system("cls");
  128. print("1) Find a hotel by city");
  129. print("2) Get all hotels");
  130. print("3) Check wallet");
  131. int choice;
  132. cin >> choice;
  133. string city;
  134. switch (choice)
  135. {
  136. case 1:
  137. listHotels(hl, wl);
  138. break;
  139. case 2:
  140. print("Enter name of city you want to find hotel at:");
  141. cin >> city;
  142. findHotelByCity(hl, city, wl);
  143. break;
  144. case 3:
  145. break;
  146. default:
  147. break;
  148. }
  149. }
  150.  
  151. void listHotels(vector<hotel> list, vector<wallet>wl)
  152. {
  153. system("cls");
  154. for (auto item : list) {
  155. print(" ");
  156. print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  157. cout << "ID: " << item.getID() << endl;
  158. cout << "Name: " << item.getHotelName() << endl;
  159. cout << "City: " << item.getCity() << endl;
  160. cout << "Rooms: " << item.getRooms() << endl;
  161. cout << "Stars: " << item.getStars() << endl;
  162. cout << "Price: " << item.getPrice() << endl;
  163. }
  164. print("Enter ID of hotel you are interested in, if you wish to go back to menu type 420:");
  165. int ID;
  166. cin >> ID;
  167. if (ID != 420) {
  168. for (auto item : list)
  169. {
  170. if (item.getID() == ID) {
  171. reserveHotel(list, item, wl);
  172. }
  173. }
  174. }
  175. else
  176. menu(list, wl);
  177.  
  178. }
  179.  
  180. void findHotelByCity(vector<hotel> list, string city, vector<wallet> wl)
  181. {
  182. system("cls");
  183. for (auto item : list)
  184. {
  185. if (item.getCity() == city) {
  186. cout << "ID: " << item.getID() << endl;
  187. cout << "Name: " << item.getHotelName() << endl;
  188. cout << "City: " << item.getCity() << endl;
  189. cout << "Rooms: " << item.getRooms() << endl;
  190. cout << "Stars: " << item.getStars() << endl;
  191. cout << "Price: " << item.getPrice() << endl;
  192. }
  193. }
  194. print("Enter ID of hotel you are interested in, if you wish to go back to menu type 420:");
  195. int ID;
  196. cin >> ID;
  197. if (ID != 420) {
  198. for (auto item : list)
  199. {
  200. if (item.getID() == ID) {
  201. reserveHotel(list, item, wl);
  202. }
  203. }
  204. }
  205. else
  206. menu(list, wl);
  207. }
  208.  
  209. void reserveHotel(vector<hotel> list,hotel instance, vector<wallet> wl)
  210. {
  211. wallet holder = validateCard(wl);
  212. printWallet(holder);
  213. cout << endl;
  214. cout << endl;
  215. if (instance.getPrice() <= holder.getMoney()) {
  216. holder.setMoney(holder.getMoney() - instance.getPrice());
  217. cout << "You successfully reserved a room in " << instance.getHotelName() << endl;
  218. cout << endl << endl;
  219. printWallet(holder);
  220. }
  221. else {
  222. cout << "You dont have enough money in your wallet." << endl;
  223. menu(list, wl);
  224. }
  225. }
  226.  
  227. wallet validateCard(vector<wallet> list)
  228. {
  229. system("cls");
  230. string ID;
  231. int CV;
  232. cout << "Enter ID number of your card: ";
  233. cin >> ID;
  234. cout << endl;
  235. cout << "Enter CV number of your card: ";
  236. cin >> CV;
  237. cout << endl;
  238.  
  239. for (auto item : list)
  240. {
  241. if (item.getID() == ID) {
  242. if (item.getCV() == CV) {
  243. return item;
  244. }
  245. }
  246. else {
  247. cout << "Fail." << endl;
  248. }
  249. }
  250. }
  251.  
  252. void printWallet(wallet inst)
  253. {
  254. cout << "Holder name: " << inst.getName() << " " << inst.getLName() << endl;
  255. cout << "ID: " << inst.getID() << endl;
  256. cout << "Balance: " << inst.getMoney() << endl;
  257. }
  258.  
  259. void print(string text)
  260. {
  261. cout << text << endl;
  262. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement