Advertisement
Guest User

mdmodv

a guest
Nov 20th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.78 KB | None | 0 0
  1. #include "Corporation.h"
  2.  
  3. using namespace std;
  4.  
  5. Utilities u1;
  6. Menu corpMenu;
  7.  
  8. Corporation * Corporation::instance()
  9. {
  10.  
  11. if (!singleton_instance) {
  12. singleton_instance = new Corporation;
  13. }
  14.  
  15. return singleton_instance;
  16. }
  17.  
  18. void Corporation::login() {
  19.  
  20. string password, user;
  21. bool foundUser = false;
  22. bool foundSupplier = false;
  23.  
  24. cout << "Username: ";
  25. getline(cin, user);
  26.  
  27. if (cin.eof()) {
  28. u1.cancelMessage();
  29. corpMenu.MainMenu();
  30. }
  31.  
  32. cout << "\nPassword: "; cin >> password;
  33.  
  34. u1.cinClear();
  35.  
  36. if (cin.eof()) {
  37. u1.cancelMessage();
  38. corpMenu.MainMenu();
  39. }
  40.  
  41. for (size_t i = 0; i != usersVec.size(); i++) {
  42. if (usersVec.at(i).getUsername() == user && usersVec.at(i).getPassword() == password) {
  43. Corporation::instance()->username = user;
  44. foundUser = true;
  45. u1.clearScreen();
  46. corpMenu.UsersMenu();
  47. return;
  48. }
  49. }
  50.  
  51. for (size_t i = 0; i != suppliersVec.size(); i++) {
  52. if (suppliersVec.at(i).getName() == user && suppliersVec.at(i).getPassword() == password) {
  53. Corporation::instance()->supplierName = user;
  54. foundSupplier = true;
  55. u1.clearScreen();
  56. corpMenu.SuppliersMenu();
  57. return;
  58. }
  59. }
  60.  
  61. if (!foundUser && !foundSupplier) {
  62. cout << "\n ERROR: The username/password you inserted do not exist.";
  63. Sleep(1500);
  64. u1.cinClear();
  65. return;
  66. }
  67.  
  68. }
  69.  
  70. //Checks existance of the users file
  71. bool Corporation::foundUsersFile(string usersFile) {
  72.  
  73. fstream f;
  74.  
  75. f.open(usersFile);
  76.  
  77. if (f.fail()) {
  78. f.close();
  79. u1.setColor(12); cerr << "\n ERROR: " << usersFile << " (users file) could not be found!\n Verify the directory!\n\n"; u1.setColor(15);
  80. return false;
  81. }
  82.  
  83. f.close();
  84.  
  85. this->usersFile = usersFile;
  86. return true;
  87. }
  88.  
  89. //Loads the users file to memory (Users vector)
  90. void Corporation::loadUsers() {
  91.  
  92. string line;
  93. fstream f;
  94.  
  95. f.open(usersFile);
  96.  
  97. while (getline(f, line)) {
  98.  
  99. string username = line.substr(0, line.find(" ; "));
  100. line.erase(0, line.find(" ; ") + 3);
  101. string password = line.substr(0, line.find(" ; "));
  102. line.erase(0, line.find(" ; ") + 3);
  103. long nif = stol(line.substr(0, line.find(" ; ")));
  104. line.erase(0, line.find(" ; ") + 3);
  105. int points = stoi(line.substr(0, line.length()));
  106.  
  107. usersVec.push_back(Users(username, password, nif, points));
  108. }
  109. f.close();
  110. return;
  111. }
  112.  
  113. //Loads memory to the users file
  114. void Corporation::saveUsers() {
  115.  
  116. ofstream f("temp.txt");
  117.  
  118. for (size_t i = 0; i < usersVec.size(); i++) {
  119. f << usersVec[i].getUsername() << " ; " << usersVec[i].getPassword() << " ; " << usersVec[i].getNif() << " ; " << usersVec[i].getPoints() << endl;
  120. }
  121.  
  122. f.close();
  123.  
  124. remove(usersFile.c_str());
  125. rename("temp.txt", usersFile.c_str());
  126.  
  127. return;
  128. }
  129.  
  130. //Adds a user to the users vector
  131. void Corporation::registerUser() {
  132.  
  133. string user, password, nif;
  134.  
  135. cout << "\n Name: "; getline(cin, user);
  136.  
  137. if (cin.eof()) {
  138. u1.cancelMessage();
  139. corpMenu.RegisterMenu();
  140. }
  141.  
  142. for (unsigned int index = 0; index != user.size(); index++) {
  143. if (!isalpha(user[index]) && user[index] != ' ') {
  144. u1.setColor(12); cerr << " ERROR: Name must only contain alphabetic characters. "; u1.setColor(15);
  145. Sleep(3000);
  146. u1.clearScreen();
  147. u1.cinClear();
  148. corpMenu.RegisterMenu();
  149. }
  150. }
  151.  
  152. for (unsigned int index2 = 0; index2 != usersVec.size(); index2++) {
  153. if (usersVec.at(index2).getUsername() == user) {
  154. u1.setColor(12); cerr << " ERROR: The username you selected already exists. Please choose another one. "; u1.setColor(15);
  155. Sleep(3000);
  156. u1.clearScreen();
  157. u1.cinClear();
  158. corpMenu.RegisterMenu();
  159. }
  160. }
  161.  
  162. cout << "\n Password: "; cin >> password;
  163.  
  164. u1.cinClear();
  165.  
  166. for (unsigned int index3 = 0; index3 != password.size(); index3++) {
  167. if (!isalnum(password[index3])) {
  168. u1.setColor(12); cerr << " ERROR: Password cannot contain special characters. "; u1.setColor(15);
  169. Sleep(3000);
  170. u1.clearScreen();
  171. corpMenu.RegisterMenu();
  172. }
  173. }
  174.  
  175. cout << "\n NIF: "; cin >> nif;
  176. u1.cinClear();
  177.  
  178. for (unsigned int index4 = 0; index4 != nif.size(); index4++) {
  179. if (!isdigit(nif[index4])) {
  180. u1.setColor(12); cerr << " ERROR: NIF can only contain digits. "; u1.setColor(15);
  181. Sleep(3000);
  182. u1.clearScreen();
  183. corpMenu.RegisterMenu();
  184. }
  185. }
  186.  
  187. for (unsigned int index5 = 0; index5 != usersVec.size(); index5++) {
  188. if (usersVec.at(index5).getNif() == stoi(nif)) {
  189. u1.setColor(12); cerr << " ERROR: The NIF you selected was already found in our system. Probably you already have an account. "; u1.setColor(15);
  190. Sleep(3000);
  191. u1.clearScreen();
  192. corpMenu.RegisterMenu();
  193. }
  194.  
  195. }
  196.  
  197. if (nif.size() != 9) {
  198. u1.setColor(12); cerr << " ERROR: The NIF must have 9 digits. "; u1.setColor(15);
  199. Sleep(3000);
  200. u1.clearScreen();
  201. corpMenu.RegisterMenu();
  202. }
  203.  
  204. if (cin.eof()) {
  205. u1.cancelMessage();
  206. corpMenu.RegisterMenu();
  207. }
  208. usersVec.push_back(Users(user, password, stol(nif), 0));
  209. u1.clearScreen();
  210. return;
  211. }
  212.  
  213. bool Corporation::foundSuppliersFile(string suppliersFile) {
  214.  
  215. fstream f;
  216.  
  217. f.open(suppliersFile);
  218.  
  219. if (f.fail()) {
  220. f.close();
  221. u1.setColor(12); cerr << "\n ERROR: " << suppliersFile << " (suppliers file) could not be found!\n Verify the directory!\n\n"; u1.setColor(15);
  222. return false;
  223. }
  224.  
  225. f.close();
  226.  
  227. this->suppliersFile = suppliersFile;
  228. return true;
  229. }
  230.  
  231. void Corporation::loadRents()
  232. {
  233. Rent tmp;
  234. fstream r;
  235. float price;
  236. r.open("rents.txt");
  237. string lineRents;
  238. while (getline(r, lineRents)) {
  239. long nif = stol(u1.trim(lineRents.substr(0, lineRents.find(" ; "))));
  240. lineRents.erase(0, lineRents.find(" ; ") + 3);
  241.  
  242. string typeRent = u1.trim(lineRents.substr(0, lineRents.find(" ; ")));
  243. lineRents.erase(0, lineRents.find(" ; ") + 3);
  244. if (typeRent == "Hotel") {
  245. string nameHotel = lineRents.substr(0, lineRents.find(" ; "));
  246. lineRents.erase(0, lineRents.find(" ; ") + 3);
  247. string city = lineRents.substr(0, lineRents.find(" ; "));
  248. lineRents.erase(0, lineRents.find(" ; ") + 3);
  249. unsigned int startDay = stoi(lineRents.substr(0, lineRents.find("/")));
  250. lineRents.erase(0, lineRents.find("/") + 1);
  251. unsigned int startMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  252. lineRents.erase(0, lineRents.find("/") + 1);
  253. unsigned int startYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  254. lineRents.erase(0, lineRents.find(" ; ") + 3);
  255. unsigned int endDay = stoi(lineRents.substr(0, lineRents.find("/")));
  256. lineRents.erase(0, lineRents.find("/") + 1);
  257. unsigned int endMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  258. lineRents.erase(0, lineRents.find("/") + 1);
  259. unsigned int endYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  260. lineRents.erase(0, lineRents.find(" ; ") + 3);
  261. string roomType = u1.trim(lineRents.substr(0, lineRents.find(" ; ")));
  262. lineRents.erase(0, lineRents.find(" ; ") + 3);
  263. price = stof(lineRents.substr(0, lineRents.find(" ; ")));
  264. lineRents.erase(0, lineRents.find(" ; ") + 3);
  265. unsigned int numPeople = stoi(lineRents);
  266. lineRents.erase(0, lineRents.length());
  267. tmp = Hotel(nif, typeRent, nameHotel, city, Date(startDay, startMonth, startYear), Date(endDay, endMonth, endYear), roomType, price, numPeople);
  268.  
  269. }
  270. else if (typeRent == "Bed'n'Breakfast") {
  271. string nameBB = lineRents.substr(0, lineRents.find(" ; "));
  272. lineRents.erase(0, lineRents.find(" ; ") + 3);
  273. string city = lineRents.substr(0, lineRents.find(" ; "));
  274. lineRents.erase(0, lineRents.find(" ; ") + 3);
  275. unsigned int startDay = stoi(lineRents.substr(0, lineRents.find("/")));
  276. lineRents.erase(0, lineRents.find("/") + 1);
  277. unsigned int startMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  278. lineRents.erase(0, lineRents.find("/") + 1);
  279. unsigned int startYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  280. lineRents.erase(0, lineRents.find(" ; ") + 3);
  281. unsigned int endDay = stoi(lineRents.substr(0, lineRents.find("/")));
  282. lineRents.erase(0, lineRents.find("/") + 1);
  283. unsigned int endMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  284. lineRents.erase(0, lineRents.find("/") + 1);
  285. unsigned int endYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  286. lineRents.erase(0, lineRents.find(" ; ") + 3);
  287. price = stof(lineRents.substr(0, lineRents.find(" ; ")));
  288. lineRents.erase(0, lineRents.find(" ; ") + 3);
  289. unsigned int numPeople = stoi(lineRents);
  290. lineRents.erase(0, lineRents.length());
  291.  
  292. tmp = bedNbreakfast(nif, typeRent, nameBB, city, Date(startDay, startMonth, startYear), Date(endDay, endMonth, endYear), price, numPeople);
  293.  
  294. }
  295. else if (typeRent == "Shared House") {
  296. string nameSH = lineRents.substr(0, lineRents.find(" ; "));
  297. lineRents.erase(0, lineRents.find(" ; ") + 3);
  298. string city = lineRents.substr(0, lineRents.find(" ; "));
  299. lineRents.erase(0, lineRents.find(" ; ") + 3);
  300. unsigned int startDay = stoi(lineRents.substr(0, lineRents.find("/")));
  301. lineRents.erase(0, lineRents.find("/") + 1);
  302. unsigned int startMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  303. lineRents.erase(0, lineRents.find("/") + 1);
  304. unsigned int startYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  305. lineRents.erase(0, lineRents.find(" ; ") + 3);
  306. unsigned int endDay = stoi(lineRents.substr(0, lineRents.find("/")));
  307. lineRents.erase(0, lineRents.find("/") + 1);
  308. unsigned int endMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  309. lineRents.erase(0, lineRents.find("/") + 1);
  310. unsigned int endYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  311. lineRents.erase(0, lineRents.find(" ; ") + 3);
  312. price = stof(lineRents.substr(0, lineRents.find(" ; ")));
  313. lineRents.erase(0, lineRents.find(" ; ") + 3);
  314. unsigned int numPeople = stoi(lineRents);
  315. lineRents.erase(0, lineRents.length());
  316. tmp = sharedHouse(nif, typeRent, nameSH, city, Date(startDay, startMonth, startYear), Date(endDay, endMonth, endYear), price, numPeople);
  317.  
  318. }
  319. else if (typeRent == "Flat") {
  320. string nameFlat = lineRents.substr(0, lineRents.find(" ; "));
  321. lineRents.erase(0, lineRents.find(" ; ") + 3);
  322. string city = lineRents.substr(0, lineRents.find(" ; "));
  323. lineRents.erase(0, lineRents.find(" ; ") + 3);
  324. unsigned int startDay = stoi(lineRents.substr(0, lineRents.find("/")));
  325. lineRents.erase(0, lineRents.find("/") + 1);
  326. unsigned int startMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  327. lineRents.erase(0, lineRents.find("/") + 1);
  328. unsigned int startYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  329. lineRents.erase(0, lineRents.find(" ; ") + 3);
  330. unsigned int endDay = stoi(lineRents.substr(0, lineRents.find("/")));
  331. lineRents.erase(0, lineRents.find("/") + 1);
  332. unsigned int endMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  333. lineRents.erase(0, lineRents.find("/") + 1);
  334. unsigned int endYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  335. lineRents.erase(0, lineRents.find(" ; ") + 3);
  336. price = stof(lineRents.substr(0, lineRents.find(" ; ")));
  337. lineRents.erase(0, lineRents.find(" ; ") + 3);
  338. unsigned int numPeople = stoi(lineRents);
  339. lineRents.erase(0, lineRents.length());
  340. tmp = flat(nif, typeRent, nameFlat, city, Date(startDay, startMonth, startYear), Date(endDay, endMonth, endYear), price, numPeople);
  341. }
  342. else if (typeRent == "Apartment") {
  343. string nameApartment = u1.trim(lineRents.substr(0, lineRents.find(" ; ")));
  344. lineRents.erase(0, lineRents.find(" ; ") + 3);
  345. string city = u1.trim(lineRents.substr(0, lineRents.find(" ; ")));
  346. lineRents.erase(0, lineRents.find(" ; ") + 3);
  347. unsigned int startDay = stoi(lineRents.substr(0, lineRents.find("/")));
  348. lineRents.erase(0, lineRents.find("/") + 1);
  349. unsigned int startMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  350. lineRents.erase(0, lineRents.find("/") + 1);
  351. unsigned int startYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  352. lineRents.erase(0, lineRents.find(" ; ") + 3);
  353. unsigned int endDay = stoi(lineRents.substr(0, lineRents.find("/")));
  354. lineRents.erase(0, lineRents.find("/") + 1);
  355. unsigned int endMonth = stoi(lineRents.substr(0, lineRents.find("/")));
  356. lineRents.erase(0, lineRents.find("/") + 1);
  357. unsigned int endYear = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  358. lineRents.erase(0, lineRents.find(" ; ") + 3);
  359. price = stof(lineRents.substr(0, lineRents.find(" ; ")));
  360. lineRents.erase(0, lineRents.find(" ; ") + 3);
  361. unsigned int numPeople = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  362. int numRooms = stoi(lineRents.substr(0, lineRents.find(" ; ")));
  363. bool k, s, l;
  364. string x = u1.trim(lineRents.substr(0, lineRents.find(" ; ")));
  365. lineRents.erase(0, lineRents.find(" ; ") + 3);
  366. if (x == "true")
  367. k = true;
  368. else
  369. k = false;
  370. x = u1.trim(lineRents.substr(0, lineRents.find(" ; ")));
  371. lineRents.erase(0, lineRents.find(" ; ") + 3);
  372. if (x == "true")
  373. s = true;
  374. else
  375. s = false;
  376. x = u1.trim(lineRents);
  377. lineRents.erase(0, lineRents.length());
  378. if (x == "true")
  379. l = true;
  380. else
  381. l = false;
  382.  
  383. tmp = apartment(nif, typeRent, nameApartment, city, Date(startDay, startMonth, startYear), Date(endDay, endMonth, endYear), price, numPeople, numRooms, k, s, l);
  384. }
  385. string reservationsLine;
  386. getline(r, reservationsLine);
  387. int numIterations = stoi(u1.trim(reservationsLine.substr(0, reservationsLine.find(" ; "))));
  388. reservationsLine.erase(0, reservationsLine.find(" ; ") + 3);
  389. for (int j = 0; j < numIterations; j++) {
  390.  
  391. long nifR = stol(u1.trim(reservationsLine.substr(0, reservationsLine.find(" ; "))));
  392. reservationsLine.erase(0, reservationsLine.find(" ; ") + 3);
  393.  
  394. Date d1, d2;
  395. d1 = reservationsLine.substr(0, reservationsLine.find(" ; "));
  396. reservationsLine.erase(0, reservationsLine.find(" ; ") + 3);
  397.  
  398. d2 = reservationsLine.substr(0, reservationsLine.find(" ; "));
  399.  
  400. if (j == (numIterations - 1))
  401. reservationsLine.erase(0, reservationsLine.length());
  402. else
  403. reservationsLine.erase(0, reservationsLine.find(" ; ") + 3);
  404. price = (d2.minus(d1))*price;
  405. Reservation newR(nifR, price, d1, d2);
  406. tmp.setReservation(newR);
  407. }
  408. rentsVec.push_back(tmp);
  409. }
  410. }
  411.  
  412. void Corporation::loadSuppliers() {
  413.  
  414. string line, lineRents;
  415. fstream f;
  416. vector<Rent> xVec;
  417.  
  418. double price;
  419. f.open(suppliersFile);
  420.  
  421. while (getline(f, line)) {
  422.  
  423. string supplierName = line.substr(0, line.find(" ; "));
  424. line.erase(0, line.find(" ; ") + 3);
  425. string password = line.substr(0, line.find(" ; "));
  426. line.erase(0, line.find(" ; ") + 3);
  427. long nif = stol(line.substr(0, line.find(" ; ")));
  428. line.erase(0, line.find(" ; ") + 3);
  429. string address = line;
  430. line.erase(0, line.length());
  431.  
  432. suppliersVec.push_back(Supplier(supplierName, password, nif, address));
  433. }
  434.  
  435. f.close();
  436.  
  437. return;
  438. }
  439.  
  440. //Loads suppliersVec to the .txt file
  441. void Corporation::saveSuppliers()
  442. {
  443. ofstream f("tempSuppliers.txt");
  444.  
  445. for (int i = 0; i < suppliersVec.size(); i++)
  446. {
  447. int j;
  448. f << suppliersVec[i].getName() << " ; " << suppliersVec[i].getPassword() << " ; " << suppliersVec[i].getNif() << " ; " << suppliersVec[i].getAddress() << "\n";
  449. }
  450.  
  451.  
  452. f.close();
  453. remove(suppliersFile.c_str());
  454. rename("tempSuppliers.txt", suppliersFile.c_str());
  455.  
  456. return;
  457. }
  458.  
  459. void Corporation::saveRents()
  460. {
  461. int j;
  462. ofstream r("rents.txt");
  463. for (j = 0; j < rentsVec.size(); j++)
  464. {
  465. vector<Rent> x;
  466. x = rentsVec;
  467. if (x[j].getTypeRent() == "Hotel")
  468. {
  469. r << rentsVec[j].getNif() << " ; ";
  470. r << "Hotel ; " << x[j].getName() << " ; " << x[j].getCity() << " ; ";
  471. r << x[j].getDataInicio() << " ; ";
  472. r << x[j].getDataFim() << " ; ";
  473. r << x[j].getType() << " ; " << x[j].getPrice() << " ; " << x[j].getNumPeople();
  474. r << "\n";
  475. }
  476.  
  477. if (x[j].getTypeRent() == "Bed'n'Breakfast")
  478. {
  479. r << rentsVec[j].getNif() << " ; ";
  480. r << "Bed'n'Breakfast ; " << x[j].getName() << " ; " << u1.trim(x[j].getCity()) << " ; ";
  481. r << x[j].getDataInicio() << " ; ";
  482. r << x[j].getDataFim() << " ; ";
  483. r << x[j].getPrice() << " ; " << x[j].getNumPeople();
  484. r << "\n";
  485. }
  486. if (x[j].getTypeRent() == "Shared House")
  487. {
  488. r << rentsVec[j].getNif() << " ; ";
  489. r << "Shared House ; " << x[j].getName() << " ; " << u1.trim(x[j].getCity()) << " ; ";
  490. r << x[j].getDataInicio() << " ; ";
  491. r << x[j].getDataFim() << " ; ";
  492. r << x[j].getPrice() << " ; " << x[j].getNumPeople();
  493. r << "\n";
  494. }
  495. if (x[j].getTypeRent() == "Flat")
  496. {
  497. r << rentsVec[j].getNif() << " ; ";
  498. r << "Flat ; " << x[j].getName() << " ; " << u1.trim(x[j].getCity()) << " ; ";
  499. r << x[j].getDataInicio() << " ; ";
  500. r << x[j].getDataFim() << " ; ";
  501. r << x[j].getPrice() << " ; " << x[j].getNumPeople();
  502. r << "\n";
  503. }
  504. if (x[j].getTypeRent() == "Apartment")
  505. {
  506. r << rentsVec[j].getNif() << " ; ";
  507. r << "Apartment ; " << x[j].getName() << " ; " << u1.trim(x[j].getCity()) << " ; ";
  508. r << x[j].getDataInicio() << " ; ";
  509. r << x[j].getDataFim() << " ; ";
  510. r << x[j].getPrice() << " ; " << x[j].getNumPeople() << " ; ";
  511. r << x[j].getNumRooms() << " ; ";
  512. r << x[j].getKitchen() << " ; " << x[j].getSuite() << " ; " << x[j].getLivingRoom();
  513. r << "\n";
  514. }
  515. if (x[j].getReservations().size() == 0)
  516. r << x[j].getReservations().size() << " ;\n";
  517. else {
  518. r << x.at(j).getReservations().size() << " ; ";
  519. for (int k = 0; k < x.at(j).getReservations().size(); k++)
  520. {
  521. if (k == (x[j].getReservations().size() - 1))
  522. r << x[j].getReservations()[k].getnif() << " ; " << x[j].getReservations()[k].getDate1() << " ; " << x[j].getReservations()[k].getDate2();
  523. else
  524. r << x[j].getReservations()[k].getnif() << " ; " << x[j].getReservations()[k].getDate1() << " ; " << x[j].getReservations()[k].getDate2() << " ; ";
  525. }
  526. r << endl;
  527. }
  528.  
  529. }
  530. r.close();
  531. return;
  532. }
  533.  
  534. //Adds a supplier to the suppliers vector
  535. void Corporation::registerSupplier() {
  536.  
  537. string user, password, nif, address;
  538.  
  539.  
  540. cout << "\n Name: ";
  541. getline(cin, user);
  542.  
  543. if (cin.eof()) {
  544. u1.cancelMessage();
  545. corpMenu.RegisterMenu();
  546. }
  547.  
  548. for (unsigned int index = 0; index != user.size(); index++) {
  549. if (!isalpha(user.at(index)) && user.at(index) != ' ') {
  550. u1.setColor(12); cerr << " ERROR: Name must only contain alphabetic characters. "; u1.setColor(15);
  551. Sleep(1500);
  552. cerr << " ERROR: Name must only contain alphabetic characters. ";
  553. u1.clearScreen();
  554. u1.cinClear();
  555. corpMenu.RegisterMenu();
  556. }
  557. }
  558.  
  559. for (unsigned int index2 = 0; index2 != suppliersVec.size(); index2++) {
  560. if (suppliersVec.at(index2).getName() == user) {
  561. u1.setColor(12); cerr << " ERROR: The username you selected already exists. Please choose another one. "; u1.setColor(15);
  562. Sleep(3000);
  563. u1.clearScreen();
  564. u1.cinClear();
  565. corpMenu.RegisterMenu();
  566. }
  567. }
  568.  
  569. cout << "\n Password: "; cin >> password;
  570.  
  571. u1.cinClear();
  572.  
  573. for (unsigned int index3 = 0; index3 != password.size(); index3++) {
  574. if (!isalnum(password.at(index3))) {
  575. u1.setColor(12); cerr << " ERROR: Password cannot contain special characters. "; u1.setColor(15);
  576. Sleep(3000);
  577. u1.clearScreen();
  578. corpMenu.RegisterMenu();
  579. }
  580. }
  581.  
  582. cout << "\n NIF: "; cin >> nif;
  583. u1.cinClear();
  584.  
  585. for (unsigned int index4 = 0; index4 != nif.size(); index4++) {
  586. if (!isdigit(nif.at(index4))) {
  587. u1.setColor(12); cerr << " ERROR: NIF can only contain digits. "; u1.setColor(15);
  588. Sleep(3000);
  589. u1.clearScreen();
  590. corpMenu.RegisterMenu();
  591. }
  592. }
  593.  
  594. for (unsigned int index5 = 0; index5 != suppliersVec.size(); index5++) {
  595. if (suppliersVec.at(index5).getNif() == stoi(nif)) {
  596. u1.setColor(12); cerr << " ERROR: The NIF you selected was already found in our system. Probably you already have an account. "; u1.setColor(15);
  597. Sleep(3000);
  598. u1.clearScreen();
  599. corpMenu.RegisterMenu();
  600. }
  601.  
  602. }
  603.  
  604. if (nif.size() != 9) {
  605. u1.setColor(12); cerr << " ERROR: The NIF must have 9 digits. "; u1.setColor(15);
  606. Sleep(3000);
  607. u1.clearScreen();
  608. corpMenu.RegisterMenu();
  609. }
  610.  
  611. if (cin.eof()) {
  612. u1.cancelMessage();
  613. corpMenu.RegisterMenu();
  614. }
  615.  
  616. cout << "\n Address: "; cin >> address;
  617.  
  618. u1.cinClear();
  619.  
  620. for (unsigned int i = 0; i != suppliersVec.size(); i++) {
  621. if (suppliersVec.at(i).getAddress() == address) {
  622. u1.setColor(12); cerr << " ERROR: The address you selected was already found in our system. Probably you already have an account. "; u1.setColor(15);
  623. Sleep(3000);
  624. u1.clearScreen();
  625. corpMenu.RegisterMenu();
  626. }
  627. }
  628.  
  629. if (cin.eof()) {
  630. u1.cancelMessage();
  631. corpMenu.RegisterMenu();
  632. }
  633.  
  634. suppliersVec.push_back(Supplier(user, password, stol(nif), address));
  635. u1.clearScreen();
  636. return;
  637. }
  638.  
  639. //Orders Suppliers
  640. void Corporation::orderSuppliersVec()
  641. {
  642. int i, j;
  643. for (i = 0; i < (suppliersVec.size() - 1); i++) {
  644. for (j = 0; j < suppliersVec.size() - 1; j++)
  645. {
  646. if (suppliersVec[j].getName() > suppliersVec[j + 1].getName())
  647. {
  648. string before, after;
  649. after = suppliersVec[j].getName();
  650. before = suppliersVec[j + 1].getName();
  651. suppliersVec[j + 1].setName(after);
  652. suppliersVec[j].setName(before);
  653. }
  654. }
  655. }
  656.  
  657. }
  658.  
  659. void Corporation::orderRentsVec()
  660. {
  661. int i;
  662. if (rentsVec.size() == 1)
  663. return;
  664. for (i = 0; i < (rentsVec.size() - 1); i++) {
  665. if (rentsVec[i].getPrice() > rentsVec[i + 1].getPrice())
  666. {
  667. Rent before, after;
  668. after = rentsVec[i];
  669. before = rentsVec[i + 1];
  670. rentsVec[i + 1] = after;
  671. rentsVec[i] = before;
  672. }
  673. }
  674.  
  675. }
  676.  
  677. //Adds rent to logged-in supplier
  678. void Corporation::makeRent() {
  679.  
  680. bool isIn = true;
  681. Date d1, d2;
  682. string cinNumIter, cinChoice;
  683. int numIteration, choice;
  684.  
  685. while (isIn) {
  686.  
  687. u1.setColor(14); cout << "\n ::| CREATE RENT |::\n"; u1.setColor(15);
  688.  
  689. cout << "\nHow many rents do you wish to be made available? : ";
  690. cin >> cinNumIter;
  691.  
  692. if (cin.eof()) {
  693. u1.cancelMessage();
  694. corpMenu.SuppliersMenu();
  695. }
  696.  
  697. for (size_t i = 0; i < cinNumIter.size(); i++) {
  698. if (!isdigit(cinNumIter.at(i))) {
  699. u1.setColor(12); cerr << endl << " ERROR: Input can only contain digits. "; u1.setColor(15);
  700. Sleep(1500);
  701. cout << endl << " Please try again. If you wish to cancel the operation press CTRL + Z.";
  702. Sleep(1500);
  703. u1.cinClear();
  704. u1.clearScreen();
  705. }
  706. else {
  707.  
  708. numIteration = stoi(cinNumIter);
  709. cin.clear();
  710. isIn = false;
  711. }
  712. }
  713. }
  714. long nif;
  715. isIn = true;
  716. for (int j = 0; j < rentsVec.size(); j++)
  717. for (int i = 0; i < suppliersVec.size(); i++)
  718. if (suppliersVec[i].getName() == Corporation::instance()->username) {
  719. nif = suppliersVec[i].getNif();
  720. }
  721.  
  722. for (int i = 0; i < numIteration; i++) {
  723.  
  724.  
  725. u1.clearScreen();
  726. cout << "What is the type of rent? \n1 - Hotel\n2 - Bed'n'Breakfast\n3 - Apartment\n4 - Flat\n5 - Shared House\n\n";
  727. cout << "Select the number corresponding to the option you wish to select: ";
  728. cin >> cinChoice;
  729.  
  730. if (cin.eof()) {
  731. u1.cancelMessage();
  732. corpMenu.SuppliersMenu();
  733. }
  734.  
  735. if (stoi(cinChoice) < 1 || stoi(cinChoice) > 5) {
  736. u1.setColor(12); cerr << endl << " ERROR: Input can only range from 1 to 5. "; u1.setColor(15);
  737. Sleep(1500);
  738. u1.cinClear();
  739. corpMenu.SuppliersMenu();
  740. }
  741.  
  742. for (size_t i = 0; i < cinChoice.size(); i++) {
  743. if (!isdigit(cinChoice.at(i))) {
  744. u1.setColor(12); cerr << endl << " ERROR: Input can only contain digits. "; u1.setColor(15);
  745. Sleep(1500);
  746. u1.cinClear();
  747. corpMenu.SuppliersMenu();
  748. }
  749. }
  750.  
  751. choice = stoi(cinChoice);
  752.  
  753. if (choice == 1) {
  754. u1.clearScreen();
  755. Hotel h;
  756. rentsVec.push_back(h.buildRent(nif));
  757. }
  758. if (choice == 2) {
  759. u1.clearScreen();
  760. bedNbreakfast bnb;
  761. rentsVec.push_back(bnb.buildRent(nif));
  762. }
  763. if (choice == 3) {
  764. u1.clearScreen();
  765. flat fl;
  766. rentsVec.push_back(fl.buildRent(nif));
  767. break;
  768. }
  769. if (choice == 4) {
  770. u1.clearScreen();
  771. apartment ap;
  772. rentsVec.push_back(ap.buildRent(nif));
  773. break;
  774. }
  775. if (choice == 5) {
  776. u1.clearScreen();
  777. sharedHouse sh;
  778. rentsVec.push_back(sh.buildRent(nif));
  779. break;
  780. }
  781. }
  782. u1.successMessage();
  783.  
  784. return;
  785.  
  786. }
  787.  
  788.  
  789.  
  790. void Corporation::makeReservation()
  791. {
  792.  
  793. string city, nameRent, typeRent, type;
  794. unsigned int n_people, n, counter = 1, option;
  795. bool isIn = true;
  796. float xPrice;
  797.  
  798. #pragma warning(disable : 4996)
  799. time_t ti = time(0);
  800. struct tm * now = localtime(&ti);
  801. unsigned int year = 1900 + now->tm_year, month = 1 + now->tm_mon, day = now->tm_mday;
  802. Date real_date = Date(day, month, year);
  803.  
  804. city = Corporation::instance()->cities();
  805. u1.clearScreen();
  806.  
  807. string dateB, dateE;
  808.  
  809. while (isIn) {
  810. cout << "\nDate of check-in: "; cin >> dateB;
  811.  
  812. Date date1 = Date(dateB);
  813.  
  814. if (cin.eof()) {
  815. u1.cancelMessage();
  816. corpMenu.UsersMenu();
  817. }
  818.  
  819. if (!date1.isValid() || (real_date > date1)) {
  820. u1.setColor(12); cerr << endl << " ERROR: The date you inserted is not valid."; u1.setColor(15);
  821. Sleep(1500);
  822. cout << endl << " Please try again. If you wish to cancel the operation press CTRL + Z.";
  823. Sleep(1500);
  824. u1.cinClear();
  825. u1.clearScreen();
  826. }
  827. else {
  828. u1.cinClear();
  829. isIn = false;
  830. }
  831. }
  832.  
  833. isIn = true;
  834. while (isIn) {
  835. cout << "\nDate of check-out : "; cin >> dateE; cout << endl;
  836.  
  837. Date date2 = Date(dateE);
  838.  
  839. if (cin.eof()) {
  840. u1.cancelMessage();
  841. corpMenu.UsersMenu();
  842. }
  843.  
  844. if (!date2.isValid() || (real_date > date2)) {
  845. u1.setColor(12); cerr << endl << " ERROR: The date you inserted is not valid. Please use the format dd/mm/yyyy"; u1.setColor(15);
  846. Sleep(2000);
  847. cout << endl << " Please try again. If you wish to cancel the operation press CTRL + Z.";
  848. Sleep(1500);
  849. u1.cinClear();
  850. u1.clearScreen();
  851. }
  852. else {
  853. u1.cinClear();
  854. isIn = false;
  855. }
  856. }
  857.  
  858. Date date1 = Date(dateB);
  859. Date date2 = Date(dateE);
  860.  
  861. isIn = true;
  862.  
  863. while (isIn) {
  864. u1.setColor(11); cout << "Rooms available between " << date1 << " and " << date2 << " in " << city << ": \n\n"; u1.setColor(15);
  865.  
  866. for (size_t i = 0; i < rentsVec.size(); i++, counter++) {
  867. if (rentsVec[i].isValid(date1, date2)) {
  868. if (rentsVec.at(i).getTypeRent() == "Hotel") {
  869. cout << "Option " << counter << endl;
  870. cout << "Type of accommodation: " << rentsVec.at(i).getTypeRent() << endl;
  871. cout << "Name: " << rentsVec.at(i).getName() << endl;
  872. cout << "Available from: " << rentsVec.at(i).getDataInicio();
  873. cout << " To: " << rentsVec.at(i).getDataFim() << endl;
  874. cout << "Room type: " << rentsVec.at(i).getType() << endl;
  875. cout << "Price per night: " << rentsVec.at(i).getPrice() << endl;
  876. cout << "Room's capacity: " << rentsVec.at(i).getNumPeople() << endl << endl;
  877. }
  878. else if (rentsVec.at(i).getTypeRent() == "Apartment") {
  879. cout << "Option " << counter << endl;
  880. cout << "Type of accommodation: " << rentsVec.at(i).getTypeRent() << endl;
  881. cout << "Name: " << rentsVec.at(i).getName() << endl;
  882. cout << "Available from: " << rentsVec.at(i).getDataInicio();
  883. cout << " To: " << rentsVec.at(i).getDataFim() << endl;
  884. cout << "Has Kitchen: " << rentsVec.at(i).getKitchen() << endl;
  885. cout << "Has Living Room: " << rentsVec.at(i).getLivingRoom() << endl;
  886. cout << "Has Suite: " << rentsVec.at(i).getSuite() << endl;
  887. cout << "Price per night: " << rentsVec.at(i).getPrice() << endl;
  888. cout << "Room's capacity: " << rentsVec.at(i).getNumPeople() << endl << endl;
  889. }
  890. else {
  891. cout << "Option " << counter << endl;
  892. cout << "Type of accommodation: " << rentsVec.at(i).getTypeRent() << endl;
  893. cout << "Name: " << rentsVec.at(i).getName() << endl;
  894. cout << "Available from: " << rentsVec.at(i).getDataInicio();
  895. cout << " To: " << rentsVec.at(i).getDataFim() << endl;
  896. cout << "Price per night: " << rentsVec.at(i).getPrice() << endl;
  897. cout << "Room's capacity: " << rentsVec.at(i).getNumPeople() << endl << endl;
  898. }
  899. }
  900. }
  901.  
  902. cout << "Insert the option's number: ";
  903. cin >> option;
  904.  
  905. xPrice = rentsVec[option - 1].getPrice();
  906.  
  907. if (cin.eof()) {
  908. u1.cancelMessage();
  909. corpMenu.UsersMenu();
  910. }
  911.  
  912. if (cin.fail()) {
  913. u1.setColor(12); cerr << endl << " ERROR: Input is not an integer."; u1.setColor(15);
  914. Sleep(1500);
  915. cout << endl << " Please try again. If you wish to cancel the operation press CTRL + Z.";
  916. Sleep(1500);
  917. u1.cinClear();
  918. u1.clearScreen();
  919. }
  920. }
  921.  
  922. isIn = true;
  923.  
  924. while (isIn) {
  925. u1.setColor(14); cout << "\n\nCity: " << city << " From: " << date1 << " To: " << date2 << endl;
  926. cout << "\nNumber of people: ";
  927. cin >> n_people;
  928.  
  929. if (cin.eof()) {
  930. u1.cancelMessage();
  931. corpMenu.UsersMenu();
  932. }
  933.  
  934. if (cin.fail()) {
  935. u1.setColor(12); cerr << endl << " ERROR: Input is not an integer."; u1.setColor(15);
  936. Sleep(1500);
  937. cout << endl << " Please try again. If you wish to cancel the operation press CTRL + Z.";
  938. Sleep(1500);
  939. u1.cinClear();
  940. u1.clearScreen();
  941. }
  942.  
  943. for (int i = 0; i < rentsVec.size(); i++) {
  944. if (n_people > rentsVec.at(i).getNumPeople()) {
  945. u1.setColor(12); cerr << endl << " ERROR: The value you inserted exceeds the room's maximum capacity."; u1.setColor(15);
  946. Sleep(1500);
  947. cout << endl << " Please try again. If you wish to cancel the operation press CTRL + Z.";
  948. Sleep(1500);
  949. u1.cinClear();
  950. }
  951. else {
  952. cin.clear();
  953. isIn = false;
  954. }
  955. }
  956. }
  957. int nif = rentsVec[option - 1].getNif();
  958. float totalPrice = xPrice*(date2.minus(date1));
  959. rentsVec[option - 1].setReservation(Reservation(nif, totalPrice, date1, date2));
  960.  
  961. }
  962.  
  963.  
  964. void Corporation::cancelReservation()
  965. {
  966. #pragma warning(disable : 4996)
  967. time_t ti = time(0);
  968. struct tm * now = localtime(&ti);
  969. unsigned int year = 1900 + now->tm_year, month = 1 + now->tm_mon, day = now->tm_mday;
  970. Date real_date = Date(day, month, year);
  971.  
  972. long nif_user;
  973. for (int i = 0; i < usersVec.size(); i++)
  974. {
  975. if (usersVec.at(i).getUsername() == username)
  976. nif_user = usersVec.at(i).getNif();
  977. }
  978.  
  979. bool found = false;
  980. for (int j = 0; j < rentsVec.size(); j++)
  981. {
  982. for (int k = 0; k < rentsVec.at(j).getReservations().size(); k++)
  983. {
  984. if (rentsVec.at(j).getReservations().at(k).getnif() == nif_user)
  985. {
  986. found = true;
  987. }
  988. }
  989. }
  990.  
  991. if (found)
  992. {
  993. cout << "List of your reservations : " << endl << endl;
  994. for (int j = 0; j < rentsVec.size(); j++)
  995. {
  996. for (int k = 0; k < rentsVec.at(j).getReservations().size(); k++)
  997. {
  998. if (rentsVec.at(j).getReservations().at(k).getnif() == nif_user)
  999. {
  1000. cout << "City : " << rentsVec.at(j).getCity() << endl;
  1001. cout << "Type of accommodation : " << rentsVec.at(j).getTypeRent() << endl;
  1002. cout << "Name : " << rentsVec.at(j).getName() << endl;
  1003. cout << "Date of Check-in : " << rentsVec.at(j).getReservations().at(k).getDate1();
  1004. cout << "Date of Check-out : " << rentsVec.at(j).getReservations().at(k).getDate2() << endl;
  1005. cout << "Price : " << rentsVec.at(j).getReservations().at(k).getPrice() << endl;
  1006. cout << "Room's capacity: " << rentsVec.at(j).getNumPeople() << endl;
  1007. if (rentsVec.at(j).getLivingRoom() && rentsVec.at(j).getSuite() && rentsVec.at(j).getKitchen())
  1008. cout << "Includes : LivingRoom, Suite and Kitchen" << endl;
  1009. else if (rentsVec.at(j).getLivingRoom() && rentsVec.at(j).getKitchen())
  1010. cout << "Includes : LivingRoom and Kitchen" << endl;
  1011. else if (rentsVec.at(j).getLivingRoom() && rentsVec.at(j).getSuite())
  1012. cout << "Includes : LivingRoom and Suite" << endl;
  1013. else if (rentsVec.at(j).getSuite() && rentsVec.at(j).getKitchen())
  1014. cout << "Includes : Suite and Kitchen" << endl;
  1015. else if (rentsVec.at(j).getKitchen())
  1016. cout << "Includes : Kitchen" << endl;
  1017. else if (rentsVec.at(j).getSuite())
  1018. cout << "Includes : Suite" << endl;
  1019. else if (rentsVec.at(j).getLivingRoom())
  1020. cout << "Includes : LivingRoom" << endl;
  1021. }
  1022. cout << endl;
  1023. }
  1024. }
  1025. }
  1026. else
  1027. {
  1028. cout << " You havent made any reservations yet!" << endl;
  1029. Sleep(2000);
  1030. return;
  1031. }
  1032.  
  1033. string name_answer;
  1034. cout << " Which one would you like to cancel :";
  1035. getline(cin, name_answer);
  1036.  
  1037. vector<Reservation>x_vec;
  1038. for (int i = 0; i < rentsVec.size(); i++)
  1039. {
  1040. for (int j = 0; j < rentsVec.at(i).getReservations().size(); j++)
  1041. {
  1042. if(name_answer == rentsVec.at(i).getName() && nif_user == rentsVec.at(i).getReservations().at(j).getnif())
  1043. {
  1044. string answer;
  1045. cout << "Do you want to confirm ? (yes|No)";
  1046. getline(cin, answer);
  1047. if (answer == "Yes" || answer == "yes")
  1048. {
  1049. Date x = rentsVec.at(i).getReservations().at(j).getDate1() - real_date;
  1050. if (x.getYear() != 0 || x.getMonth() > 0)
  1051. cout << " You will receive " << rentsVec.at(i).getReservations().at(j).getPrice() << " euros." << endl;
  1052. else if (x.getDay() >= 15)
  1053. cout << "You will receive " << rentsVec.at(i).getReservations().at(j).getPrice() / 2 << " euros." << endl;
  1054. else
  1055. cout << "You will not receive any money." << endl;
  1056.  
  1057.  
  1058. x_vec = rentsVec.at(i).getReservations();
  1059. x_vec.erase(x_vec.begin() + j);
  1060. Sleep(4000);
  1061. }
  1062. else
  1063. {
  1064. cout << "You canceled the operation." << endl;
  1065. Sleep(2000);
  1066. return;
  1067. }
  1068. }
  1069. rentsVec.at(i).setReservationVector(x_vec);
  1070. }
  1071. }
  1072.  
  1073. for (int i = 0; i < x_vec.size(); i++)
  1074. {
  1075. cout << x_vec.at(i).getnif() << " " << x_vec.at(i).getDate1() << " " << x_vec.at(i).getDate2() << endl;
  1076. }
  1077.  
  1078. Sleep(4000);
  1079. }
  1080.  
  1081.  
  1082. bool Corporation::foundRentsFile(string rentsFile)
  1083. {
  1084. fstream f;
  1085.  
  1086. f.open(rentsFile);
  1087.  
  1088. if (f.fail()) {
  1089. f.close();
  1090. u1.setColor(12); cerr << "\n ERROR: " << rentsFile << " (suppliers file) could not be found!\n Verify the directory!\n\n"; u1.setColor(15);
  1091. return false;
  1092. }
  1093.  
  1094. f.close();
  1095.  
  1096. this->rentsFile = rentsFile;
  1097. return true;
  1098. }
  1099.  
  1100. string Corporation::cities() {
  1101.  
  1102. string *item = new string[18];
  1103. int counter = 1, option;
  1104. string cinOption;
  1105. bool run = true;
  1106.  
  1107. item[0] = "Aveiro";
  1108. item[1] = "Beja";
  1109. item[2] = "Braga";
  1110. item[3] = "Bragança";
  1111. item[4] = "Castelo Branco";
  1112. item[5] = "Coimbra";
  1113. item[6] = "Evora";
  1114. item[7] = "Faro";
  1115. item[8] = "Guarda";
  1116. item[9] = "Leiria";
  1117. item[10] = "Lisboa";
  1118. item[11] = "Portalegre";
  1119. item[12] = "Porto";
  1120. item[13] = "Santarem";
  1121. item[14] = "Setubal";
  1122. item[15] = "Viana do Castelo";
  1123. item[16] = "Vila Real";
  1124. item[17] = "Viseu";
  1125.  
  1126. u1.setColor(11); cout << "Cities available: \n\n"; u1.setColor(15);
  1127. for (size_t i = 0; i < 18; i++) {
  1128. cout << counter << " - " << item[i] << endl;
  1129. counter++;
  1130. }
  1131.  
  1132. u1.setColor(14); cout << "\nInsert the number corresponding to the city\nin which you wish to make your rent available: "; u1.setColor(15);
  1133. cin >> cinOption;
  1134.  
  1135. if (cin.eof()) {
  1136. u1.cancelMessage();
  1137. corpMenu.SuppliersMenu();
  1138. }
  1139.  
  1140. if (stoi(cinOption) < 1 || stoi(cinOption) > 18) {
  1141. u1.setColor(12); cerr << endl << " ERROR: Input can only range from 1 to 18. "; u1.setColor(15);
  1142. Sleep(1500);
  1143. cout << endl << " Please try again. If you wish to cancel the operation press CTRL + Z.";
  1144. Sleep(1500);
  1145. u1.cinClear();
  1146. }
  1147.  
  1148. for (size_t i = 0; i < cinOption.size(); i++) {
  1149. if (!isdigit(cinOption.at(i))) {
  1150. u1.setColor(12); cerr << endl << " ERROR: Input can only contain digits. "; u1.setColor(15);
  1151. Sleep(1500);
  1152. cout << endl << " Please try again. If you wish to cancel the operation press CTRL + Z.";
  1153. Sleep(1500);
  1154. u1.cinClear();
  1155. }
  1156. }
  1157.  
  1158. option = stoi(cinOption);
  1159.  
  1160. switch (option) {
  1161.  
  1162. case 1:
  1163. u1.clearScreen();
  1164. cout << item[0];
  1165. Sleep(2000);
  1166. return item[0];
  1167. case 2:
  1168. return item[1];
  1169. case 3:
  1170. return item[2];
  1171. case 4:
  1172. return item[3];
  1173. case 5:
  1174. return item[4];
  1175. case 6:
  1176. return item[5];
  1177. case 7:
  1178. return item[6];
  1179. case 8:
  1180. return item[7];
  1181. case 9:
  1182. return item[8];
  1183. case 10:
  1184. return item[9];
  1185. case 11:
  1186. return item[10];
  1187. case 12:
  1188. return item[11];
  1189. case 13:
  1190. return item[12];
  1191. case 14:
  1192. return item[13];
  1193. case 15:
  1194. return item[14];
  1195. case 16:
  1196. return item[15];
  1197. case 17:
  1198. return item[16];
  1199. case 18:
  1200. return item[17];
  1201. }
  1202. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement