Advertisement
Guest User

Code

a guest
May 17th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. #include <conio.h>
  5. #include <Windows.h>
  6. #include <fstream>
  7. using namespace std;
  8.  
  9. class FlyWATFA //Parent class for all our classes used, class is for airline
  10. {
  11. private: //used private so variable names/types are not manipulable
  12. int numberOfPlanes;
  13. int capacity;
  14. string startingLocation;
  15.  
  16. public: //public to pass to children and main
  17. FlyWATFA() //default constructor
  18. {
  19. numberOfPlanes = 10; //for the purpose of our program this is 10, but can be changed
  20. capacity = 100; //for the purpose of our program this is 100, but can be changed
  21. startingLocation = "Dubai, United Arab Emirates"; //all flights start in Dubai
  22. }
  23.  
  24. int getNumberOfPlanes() //returns number of plains when called
  25. {
  26. return numberOfPlanes;
  27. }
  28.  
  29.  
  30. int getCapacity() //returns capacity when called
  31. {
  32. return capacity;
  33. }
  34.  
  35. string getStartingLocation() //returns starting location when called
  36. {
  37. return startingLocation;
  38. }
  39.  
  40. };
  41.  
  42. class Flight : public FlyWATFA //derived of FlyWATFA class, class is for general flight information
  43. {
  44. private: //private datafields, used for general flight info
  45.  
  46. string destination;
  47. string flightNumber;
  48. string flightTime;
  49.  
  50. public:
  51. Flight() //default constructor, all attributes set to not available initially
  52. {
  53. destination = "N/A";
  54. flightNumber = "N/A";
  55. flightTime = "N/A";
  56. }
  57.  
  58. Flight(string destination, string flightNumber, string flightTime) //constructor for passing arguments
  59. {
  60. this->destination = destination; //seting attributes within the class to the passed attributes using pointer.
  61. this->flightNumber = flightNumber;
  62. this->flightTime = flightTime;
  63. }
  64.  
  65. string getDestination() //return attribute when called
  66. {
  67. return destination;
  68. }
  69.  
  70. void setDestination(string destination) //sets the destination by passing argument and using pointer to set related attribute within class to it
  71. {
  72. this->destination = destination;
  73. }
  74.  
  75. string getFlightNumber() //return attribute when called
  76. {
  77. return flightNumber;
  78. }
  79.  
  80. void setFlightNumber(string flightNumber) //sets the destination by passing argument and using pointer to set related attribute within class to it
  81. {
  82. this->flightNumber = flightNumber;
  83. }
  84.  
  85. string getFlightTime() //return attribute when called
  86. {
  87. return flightTime;
  88. }
  89.  
  90. void setFlightTime(string flightTime) //sets the destination by passing argument and using pointer to set related attribute within class to it
  91. {
  92. this->flightTime = flightTime;
  93. }
  94.  
  95. string departureT() //function to decide flight time
  96. {
  97. int option;
  98. bool isRepeat = false; //used for repeating loop if user input invalid
  99.  
  100. cout << "These are the flight timings - " << endl;
  101. cout << "1. 09:30 A.M." << endl;
  102. cout << "2. 03:00 P.M." << endl;
  103. cout << endl;
  104. cout << "Enter when you wish to depart: ";
  105.  
  106.  
  107. do {
  108.  
  109. cin >> option;
  110. cout << endl;
  111.  
  112. switch (option) //using switch cases to choose time options
  113. {
  114. case 1: return "09:30 A.M.";
  115. case 2: return "03:00 P.M.";
  116. default:
  117. cout << "Invalid option. Please Enter a valid number: "; //user validation
  118. isRepeat = true; //sets repeat to true
  119. }
  120.  
  121. } while (isRepeat == true); //repeats do while loop if condition is met
  122.  
  123. }
  124. string cities() //function for destinations
  125. {
  126. int userChoice;
  127. bool isRepeat = false; //used for user validation, initially set to false
  128. //displays choice of destinations for user
  129. cout << "1. New York, United States of America" << endl;
  130. cout << "2. London, England" << endl;
  131. cout << "3. Tokyo, Japan" << endl;
  132. cout << "4. Amsterdam, Netherlands" << endl;
  133. cout << "5. Madrid, Spain" << endl;
  134. cout << "6. Rio de Janeiro, Brazil" << endl;
  135. cout << "7. Milan, Italy" << endl;
  136. cout << "8. Medellin, Colombia" << endl;
  137. cout << "9. Toronto, Canada" << endl;
  138. cout << "10. Manila, Philippines" << endl;
  139. cout << endl;
  140. cout << "Enter the number of the destination: ";
  141.  
  142.  
  143. do { //using do while loop for user input validation
  144.  
  145. cin >> userChoice;
  146. cout << endl;
  147.  
  148. switch (userChoice) //using swtich for each destination option
  149. {
  150. case 1: setFlightNumber("FW001"); //if user chooses this option, sets flight number attribute to what is passed
  151. return "New York, United States of America"; //returns this desitnation chosen
  152. case 2: setFlightNumber("FW002");
  153. return "London, England";
  154. case 3: setFlightNumber("FW003");
  155. return "Tokyo, Japan";
  156. case 4: setFlightNumber("FW004");
  157. return "Amsterdam, Netherlands";
  158. case 5: setFlightNumber("FW005");
  159. return "Madrid, Spain";
  160. case 6: setFlightNumber("FW006");
  161. return "Rio de Janeiro, Brazil";
  162. case 7: setFlightNumber("FW007");
  163. return "Milan, Italy";
  164. case 8: setFlightNumber("FW008");
  165. return "Medellin, Colombia";
  166. case 9: setFlightNumber("FW009");
  167. return "Toronto, Canada";
  168. case 10: setFlightNumber("FW010");
  169. return "Manila, Philippines";
  170. default:
  171. cout << "Invalid option. Please Enter a valid number: "; //default case for invalid option if user doesnt enter correct choice
  172. isRepeat = true;
  173. }
  174.  
  175. } while (isRepeat == true); //repeats if true
  176.  
  177. }
  178.  
  179. };
  180.  
  181. class Passenger : public Flight //derives from flight class, which derives from flyWatfa
  182. {
  183. private: //set to private so the names and datatypes can't be changed
  184. string name;
  185. int age;
  186. string passportNumber;
  187. string address;
  188.  
  189. public: //Public so can be manipulated
  190. Passenger() //default constructor, attriutes initially set to 0 or not available
  191. {
  192. name = "N/A";
  193. age = 0;
  194. passportNumber = "N/A";
  195. address = "N/A";
  196. }
  197.  
  198. string getName() //return attribute when called
  199. {
  200. return name;
  201. }
  202.  
  203. void setName(string name) //sets the destination by passing argument and using pointer to set related attribute within class to it
  204. {
  205. this->name = name;
  206. }
  207.  
  208. int getAge() //return attribute when called
  209. {
  210. return age;
  211. }
  212.  
  213. void setAge(int age) //sets the destination by passing argument and using pointer to set related attribute within class to it
  214. {
  215. this->age = age;
  216. }
  217.  
  218. string getPassportNumber() //return attribute when called
  219. {
  220. return passportNumber;
  221. }
  222.  
  223. void setPassportNumber(string passportNumber) //sets the destination by passing argument and using pointer to set related attribute within class to it
  224. {
  225. this->passportNumber = passportNumber;
  226. }
  227.  
  228. string getAddress() //return attribute when called
  229. {
  230. return address;
  231. }
  232.  
  233. void setAddress(string address) //sets the destination by passing argument and using pointer to set related attribute within class to it
  234.  
  235. {
  236. this->address = address;
  237. }
  238. };
  239.  
  240. class Seats : public Passenger
  241. {
  242. private:
  243. string seat;
  244. int num_firstClass;
  245. int num_busClass;
  246. int num_economy;
  247. int seatNumber;
  248.  
  249. public:
  250. Seats()
  251. {
  252. seat = "N/A";
  253. num_firstClass = 20;
  254. num_busClass = 10;
  255. num_economy = 70;
  256. seatNumber = 0;
  257. }
  258.  
  259. Seats(string seat)
  260. {
  261. this->seat = seat;
  262. }
  263.  
  264. string getSeat() //return attribute when called
  265. {
  266. return seat;
  267. }
  268. void setSeat(string seat) //sets the destination by passing argument and using pointer to set related attribute within class to it
  269.  
  270. {
  271. this->seat = seat;
  272. }
  273. int getFirstClass() //return attribute when called
  274. {
  275. return num_firstClass;
  276. }
  277. int getBusClass() //return attribute when called
  278. {
  279. return num_busClass;
  280. }
  281. int getEconomyClass() //return attribute when called
  282. {
  283. return num_economy;
  284. }
  285.  
  286. int getSeatNumber() //return attribute when called
  287. {
  288. return seatNumber;
  289. }
  290.  
  291. void setSeatNumber(int seatNumber) //sets the destination by passing argument and using pointer to set related attribute within class to it
  292.  
  293. {
  294. this->seatNumber = seatNumber;
  295. }
  296.  
  297. string seatClass() //function for choosing seating class
  298. {
  299. srand(time(NULL)); //seed for random function, based off time
  300. int userChoice; //user choice variable
  301. int num_Of_Available_FC_Seats = 20; //number of available seats in first class
  302. int num_Of_Available_BC_Seats = 10; //number of available seats in buiness class
  303. int num_Of_Available_EC_Seats = 70; //number of available seats in economy class
  304. int seatNo; //seat number
  305. bool isRepeat = false;
  306.  
  307. cout << "1. First Class($8000)" << endl;
  308. cout << "2. Business Class($3000)" << endl;
  309. cout << "3. Economy Class($1500)" << endl;
  310. cout << endl;
  311. cout << "Enter which type of seating you wish to reserve: ";
  312.  
  313.  
  314. do {
  315.  
  316. cin >> userChoice;
  317. cout << endl;
  318.  
  319. switch (userChoice)
  320. {
  321. case 1:
  322. seatNo = rand() % (20 + 1 - 1) + 1; //used to randomly choose a seat number for passenger
  323. setSeatNumber(seatNo); //calls set function passing the randomly generated value
  324. return "First Class";
  325. case 2:
  326. seatNo = rand() % (30 + 1 - 21) + 21; //used to randomly choose a seat number for passenger
  327. setSeatNumber(seatNo); //calls set function passing the randomly generated value
  328. return "Business Class";
  329. case 3:
  330. seatNo = rand() % (100 + 1 - 31) + 31; //used to randomly choose a seat number for passenger
  331. setSeatNumber(seatNo); //calls set function passing the randomly generated value
  332. return "Economy Class";
  333. default:
  334. cout << "Invalid option. Please Enter a valid number: ";
  335. isRepeat = true;
  336. }
  337.  
  338. } while (isRepeat == true);
  339.  
  340. }
  341.  
  342. };
  343.  
  344. class Fees : public Seats //derived from seats and above
  345. {
  346. private:
  347. double airlineFee;
  348. double mealFee;
  349.  
  350. public:
  351. Fees() //default constructor
  352. {
  353. airlineFee = 0;
  354. mealFee = 0;
  355. }
  356.  
  357. Fees(double airlineFee, double mealFee) //constructor passing values
  358. {
  359. this->airlineFee = airlineFee;
  360. this->mealFee = mealFee;
  361. }
  362. double getAirlineFee() //return attribute
  363. {
  364. return airlineFee;
  365. }
  366.  
  367. void setAirlineFee(double airlineFee) //set attribute
  368. {
  369. this->airlineFee = airlineFee;
  370. }
  371.  
  372. double getMealFee() // return attribute
  373. {
  374. return mealFee;
  375. }
  376.  
  377. void setMealFee(double mealFee) //set attribute
  378. {
  379. this->mealFee = mealFee;
  380. }
  381.  
  382. double classFee() //function to return class fees
  383. {
  384.  
  385. if (getSeat() == "First Class") //if the seating choice function is first class
  386. {
  387. setAirlineFee(8000); //sets the fee to this
  388. return 8000; //returns the value
  389. }
  390. else if (getSeat() == "Business Class")
  391. {
  392. setAirlineFee(3000);
  393. return 3000;
  394. }
  395. else if (getSeat() == "Economy Class")
  396. {
  397. setAirlineFee(1500);
  398. return 1500;
  399. }
  400. }
  401.  
  402. double meals() //meals function
  403. {
  404. char choice;
  405. bool repeat;
  406.  
  407. cin >> choice;
  408.  
  409. do {
  410.  
  411. if (toupper(choice) == 'Y')
  412. {
  413. repeat = false;
  414. setMealFee(20);
  415. return 20;
  416. }
  417.  
  418. else if (toupper(choice) == 'N')
  419. {
  420. repeat = false;
  421. setMealFee(0);
  422. return 0;
  423. }
  424.  
  425. else
  426. {
  427. repeat = true;
  428. cout << "Please input a valid option: ";
  429. cin >> choice;
  430. }
  431. } while (repeat == true);
  432.  
  433. }
  434.  
  435. double totalFees()
  436. {
  437. return classFee() + getMealFee();
  438. }
  439. };
  440.  
  441. class Ticket : public Fees
  442. {
  443. public:
  444. void displayTicket(int t)
  445. {
  446. cout << setw(44) << "Here is your itinerary: " << endl << endl;
  447.  
  448. cout << setw(45) << "AIRLINE TICKET " << endl;
  449. cout << "|Ticket No." << t << endl;
  450. cout << "|_________________________________________________________________________" << endl;
  451. cout << "|Airline :" << "FlyWATFA" << " " << endl;
  452. cout << "|_________________________________________________________________________" << endl;
  453. cout << "|Passenger Information : " << endl;
  454. cout << "|Name : " << getName() << " " << endl;
  455. cout << "|Age: " << getAge() << " " << endl;
  456. cout << "|Address : " << getAddress() << " " << endl;
  457. cout << "|_________________________________________________________________________" << endl;
  458. cout << "|Flight Information : " << endl;
  459. cout << "|Flight No :" << getFlightNumber() << " " << endl;
  460. cout << "|Seat No :" << getSeatNumber() << " " << endl;
  461. cout << "|Class:" << getSeat() << " " << endl;
  462. cout << "| Meal Fees: $ " << getMealFee() << endl;
  463. cout << "| Airline Fee: $ " << classFee() << endl;
  464. cout << "| Total Fee: $ " << totalFees() << endl;
  465. cout << "|_________________________________________________________________________" << endl;
  466. cout << "|Depart From: " << getStartingLocation() << " at: " << getFlightTime() << " " << endl;
  467. cout << "|Arrive At: " << getDestination() << " " << endl;
  468. cout << "|_________________________________________________________________________" << endl << endl << endl;
  469.  
  470.  
  471. }
  472.  
  473. void printTicket(int t)
  474. {
  475. string fileName = "flight_itinerary_" + to_string(t) + ".txt";
  476.  
  477.  
  478. ofstream outFile;
  479. outFile.open(fileName);
  480.  
  481. outFile << setw(45) << "AIRLINE TICKET " << endl <<
  482. "|Ticket No." << t << endl <<
  483. "|_________________________________________________________________________" << endl <<
  484. "|Airline :" << "FlyWATFA" << " " << endl <<
  485. "|_________________________________________________________________________" << endl <<
  486. "|Passenger Information : " << endl <<
  487. "|Name : " << getName() << " " << endl <<
  488. "|Age: " << getAge() << " " << endl <<
  489. "|Address : " << getAddress() << " " << endl <<
  490. "|_________________________________________________________________________" << endl <<
  491. "|Flight Information : " << endl <<
  492. "|Flight No :" << getFlightNumber() << " " << endl <<
  493. "|Seat No :" << getSeatNumber() << " " << endl <<
  494. "|Class:" << getSeat() << " " << endl <<
  495. "| Meal Fees: $ " << getMealFee() << endl <<
  496. "| Airline Fee:$ " << classFee() << endl <<
  497. "| Total Fee: $ " << totalFees() << endl <<
  498. "|_________________________________________________________________________" << endl <<
  499. "|Depart From: " << getStartingLocation() << " at: " << getFlightTime() << endl <<
  500. "|Arrive At: " << getDestination() << " " << endl <<
  501. "|_________________________________________________________________________" << endl;
  502.  
  503. outFile.close();
  504. }
  505. };
  506.  
  507.  
  508. void displayHeader() //function to display header
  509. {
  510. cout << setw(60) << ("**************************************") << endl;
  511. cout << setw(60) << ("** **") << endl;
  512. cout << setw(60) << ("** WELCOME TO **") << endl;
  513. cout << setw(60) << ("** ~ FLYWATFA ~ **") << endl;
  514. cout << setw(60) << ("** **") << endl;
  515. cout << setw(60) << ("**************************************") << endl;
  516. cout << endl;
  517. }
  518.  
  519. bool bookAnotherFlight()
  520. {
  521. char choice;
  522.  
  523. cout << "Would you like to book another flight? (Press Y or N): ";
  524.  
  525. do {
  526. cin >> choice;
  527. cin.ignore();
  528.  
  529. if (toupper(choice) == 'Y')
  530. {
  531. return true;
  532. }
  533.  
  534. else if (toupper(choice) == 'N')
  535. {
  536. cout << endl << endl << "THANK YOU FOR FLYING FLYWATFA. HAVE A NICE DAY!" << endl;
  537. return false;
  538. }
  539.  
  540. else
  541. {
  542. cout << "Invalid option. Please enter Y or N only: ";
  543. }
  544.  
  545. } while (toupper(choice) != 'Y' && toupper(choice) != 'N');
  546.  
  547. }
  548.  
  549. void mainFunc()
  550. {
  551. ofstream test("test.txt");
  552. test << "THIS IA a cggvsgxtest";
  553. //test.close();
  554.  
  555. displayHeader();
  556.  
  557. int i = 0;
  558. int ticketNumber = 0;
  559. Ticket p[100];
  560.  
  561. string passengerName;
  562. int passengerAge;
  563. double mealF;
  564. string passengerPassportNumber, city, timeOfDeparture, seat, homeAddress;
  565. ofstream registerIDFile;
  566. ofstream registerPassWFile;
  567. ifstream registerIDFile_Read;
  568. ifstream registerPassWFile_Read;
  569.  
  570. registerIDFile.open("Usernames.txt");
  571. registerPassWFile.open("Passwords.txt");
  572. char choice;
  573. char registerID[10], registerPassW[10];
  574. char loginID[10], loginPassW[10];
  575. int tries = 3;
  576.  
  577. cout << "Do you wish to Register? Press (Y/N)." << endl;
  578. cin >> choice;
  579. if (choice == 'Y' || choice == 'y')
  580. {
  581. cout << "Please register a new username" << endl;
  582. cin >> registerID;
  583. registerIDFile << registerID;
  584.  
  585. cout << "Please register a new password" << endl;
  586. cin >> registerPassW;
  587. registerPassWFile << registerPassW;
  588.  
  589. cout << "Thank you for registering with FlyWATFA" << endl << endl;
  590.  
  591.  
  592. registerIDFile.close();
  593. registerPassWFile.close();
  594. registerIDFile_Read.open("Usernames.txt");
  595. registerPassWFile_Read.open("Passwords.txt");
  596.  
  597. //if(choice == 'N' || choice == 'n')
  598. while (tries > 0)
  599. {
  600. cout << "Please Login - " << endl << endl;
  601. cout << "Enter your Username and Password to Login." << endl;
  602. cout << "Username: ";
  603. cin >> loginID;
  604. cout << "Password: ";
  605. cin >> loginPassW;
  606. cin.ignore();
  607. //if(!registerIDFile || !registerPassWFile)
  608. registerIDFile_Read >> registerID;
  609. registerPassWFile_Read >> registerPassW;
  610.  
  611.  
  612. if ((!strcmp(registerID, loginID)) && !strcmp(registerPassW, loginPassW))
  613. {
  614. tries--;
  615. cout << "The username or password you entered was invalid. Please try again" << endl;
  616. system("cls");
  617. if (tries <= 0)
  618. {
  619. cout << "There are no more log in attempts. Please try again after 1 minute." << endl;
  620. Sleep(1000);
  621. system("cls");
  622. tries = 3;
  623.  
  624. }
  625. else
  626. {
  627. cout << "that was the correct login." << endl;
  628.  
  629. do
  630. {
  631. cout << endl;
  632. cout << "Please enter your full name: ";
  633. getline(cin, passengerName);
  634. p[i].setName(passengerName);
  635.  
  636.  
  637.  
  638. cout << "Please enter your age: ";
  639. cin >> passengerAge;
  640. cin.ignore();
  641. p[i].setAge(passengerAge);
  642.  
  643. cout << "Please enter you home address: ";
  644. getline(cin, homeAddress);
  645. p[i].setAddress(homeAddress);
  646.  
  647. cout << "Please enter your passport number: ";
  648. cin >> passengerPassportNumber;
  649. cin.ignore();
  650. p[i].setPassportNumber(passengerPassportNumber);
  651.  
  652. cout << "Please choose your desired destination - " << endl << endl;
  653. city = p[i].cities();
  654. p[i].setDestination(city);
  655.  
  656. cout << "This flight departs in the morning and in the evening. At what time would you like to depart?" << endl;
  657. timeOfDeparture = p[i].departureT();
  658. p[i].setFlightTime(timeOfDeparture);
  659.  
  660. cout << "Please choose you desired seating class " << endl;
  661. seat = p[i].seatClass();
  662. p[i].setSeat(seat);
  663.  
  664. cout << "Would you like an inflight meal? (Y/N): ";
  665. mealF = p[i].meals();
  666. p[i].setMealFee(mealF);
  667.  
  668. ticketNumber++;
  669. p[i].displayTicket(ticketNumber);
  670. p[i].printTicket(ticketNumber);
  671.  
  672. i++;
  673.  
  674. } while (bookAnotherFlight() == true);
  675. }
  676. }
  677. }
  678. }
  679. registerIDFile.close();
  680. registerPassWFile.close();
  681. registerIDFile_Read.close();
  682. registerPassWFile_Read.close();
  683. }
  684. /*
  685. do
  686. {
  687. cout << "Please enter your full name: ";
  688. getline(cin, passengerName);
  689. p[i].setName(passengerName);
  690.  
  691.  
  692. cout << "Please enter your age: ";
  693. cin >> passengerAge;
  694. cin.ignore();
  695. p[i].setAge(passengerAge);
  696.  
  697. cout << "Please enter you home address: ";
  698. getline(cin, homeAddress);
  699. p[i].setAddress(homeAddress);
  700.  
  701. cout << "Please enter your passport number: ";
  702. cin >> passengerPassportNumber;
  703. cin.ignore();
  704. p[i].setPassportNumber(passengerPassportNumber);
  705.  
  706. cout << "Please choose your desired destination - " << endl << endl;
  707. city = p[i].cities();
  708. p[i].setDestination(city);
  709.  
  710. cout << "This flight departs in the morning and in the evening. At what time would you like to depart?" << endl;
  711. timeOfDeparture = p[i].departureT();
  712. p[i].setFlightTime(timeOfDeparture);
  713.  
  714. cout << "Please choose you desired seating class " << endl;
  715. seat = p[i].seatClass();
  716. p[i].setSeat(seat);
  717.  
  718. cout << "Would you like an inflight meal? (Y/N): ";
  719. mealF = p[i].meals();
  720. p[i].setMealFee(mealF);
  721.  
  722. ticketNumber++;
  723. p[i].displayTicket(ticketNumber);
  724. p[i].printTicket(ticketNumber);
  725.  
  726. i++;
  727.  
  728. } while (bookAnotherFlight() == true);
  729.  
  730. */
  731.  
  732. int main()
  733. {
  734. mainFunc();
  735.  
  736. _getch();
  737. return 0;
  738. }
  739. //comments
  740. //username password
  741. //header file
  742. /*
  743. void login()
  744. {
  745. ifstream usernamesFile;
  746. ifstream passwordsFile;
  747. usernamesFile.open("Usernames.txt");
  748. passwordsFile.open("Passwords.txt");
  749. char choice;
  750. char registerID[10], registerPassW[10];
  751. char loginID[10], loginPassW[10];
  752. int tries = 3;
  753. cout << "Do you wish to Register? Press (Y/N)." << endl;
  754. cin >> choice;
  755. if (choice == 'Y' || choice == 'y')
  756. {
  757. cout << "Enter a new username";
  758. cin >> registerID;
  759. usernamesFile >> registerID;
  760.  
  761. cout << "Enter a new password";
  762. cin >> registerPassW;
  763. passwordsFile >> registerPassW;
  764. }
  765. //if(choice == 'N' || choice == 'n')
  766. while (tries)
  767. {
  768. cout << "Enter your Username";
  769. cin >> loginID;
  770. cout << endl;
  771. cout<<"Enter Your Password";
  772. cin >> loginPassW;
  773.  
  774. if ((!strcmp(loginID, registerID)) ||!strcmp(loginPassW, registerPassW))
  775. {
  776. cout << "that was the correct login." << endl;
  777.  
  778. }
  779. else
  780. {
  781. tries--;
  782. cout << "The username or password you entered was invalid. Please try again" << endl;
  783. system("cls");
  784. if (tries <= 0)
  785. {
  786. cout << "There are no more log in attempts. Please try again after 1 minute." << endl;
  787. system("cls");
  788. Sleep(10);
  789. tries = 3;
  790. }
  791. }
  792. }
  793. usernamesFile.close();
  794. passwordsFile.close();
  795. }
  796. /*
  797. void getLoginInfo()
  798. {
  799. {
  800. FILE *F = fopen(fileName, "r");
  801.  
  802. if (F)// 1
  803. {
  804. int count = 0;
  805. while (!feof(F))
  806. {
  807. char rawLine[50];
  808.  
  809. fscanf(F, "%s", rawLine);// 2
  810.  
  811. if (!count++)// 3
  812. strcpy(id, rawLine);
  813. else
  814. strcpy(pass, rawLine);
  815.  
  816. }
  817. }
  818. else printf("Cannot open this file");
  819.  
  820. fclose(F);
  821. }
  822. }
  823. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement