Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include "invDataTypes.h"
  4. #include "reports.h"
  5.  
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int main()
  11. {
  12.     int numberOfVehicles = 20;
  13.     string vehicleTextFile = "vehicles.txt";
  14.     string OptionTextFile = "options.txt";
  15.     string OwnerTextFile = "owner.txt";
  16.     bool flag = true;
  17.     int switcher = 0;
  18.  
  19.     ///+ array of structs to hold vehicle info
  20.     vehicle vehicleInventory[numberOfVehicles];
  21.     ///+ file management
  22.     ifstream fin;
  23.  
  24.     ///+ readin vehicle info
  25.     fileHandle(fin,vehicleTextFile);
  26.     vehicleReadIn(fin,vehicleInventory,numberOfVehicles);
  27.     fin.close();
  28.     ///- end vehicle readin
  29.  
  30.     ///+ readin options info
  31.     fileHandle(fin,OptionTextFile);
  32.     optionsReadIn(fin,vehicleInventory,numberOfVehicles);
  33.     fin.close();
  34.     ///- end options readin
  35.  
  36.      ///+ readin owners info
  37.     fileHandle(fin,OwnerTextFile);
  38.     ownerReadIn(fin,vehicleInventory,numberOfVehicles);
  39.     fin.close();
  40.     ///- end owners readin
  41.  
  42.     ///+ initial output of vehicle inventory
  43.     cout << endl;
  44.     printAllVehicles(vehicleInventory,numberOfVehicles);
  45.     ///- end initial output of vehicle inventory
  46.  
  47.     ///+ switch for option selection. calls the respective function for each option. continued until FLAG becomes 'false'
  48.     while(flag == true)
  49.     {
  50.         cout << endl << "0- Print all vehicles" << endl
  51.              << "1- Print only vehicles manufactured for dealers" << endl
  52.              << "2- Print only vehicles manufactured for individuals" << endl
  53.              << "3- Print only vehicles with 4 cylinder engines" << endl
  54.              << "4- Print only vehicles with premium stereos" << endl
  55.              << "5- Print only vehicles with leather seats" << endl
  56.              << "6- Print all vehicles sorted based on Manufacture Date: " << endl
  57.              << "7- exit program: ";
  58.  
  59.         cin >> switcher;
  60.  
  61.         switch(switcher)
  62.         {
  63.         case 0:
  64.             {
  65.                printAllVehicles(vehicleInventory,numberOfVehicles);
  66.                break;
  67.             }
  68.         case 1:
  69.             {
  70.                 printDealerVehicles(vehicleInventory,numberOfVehicles);
  71.                 break;
  72.             }
  73.         case 2:
  74.             {
  75.                 printIndividualVehicles(vehicleInventory,numberOfVehicles);
  76.                 break;
  77.             }
  78.         case 3:
  79.             {
  80.                 printFourCyln(vehicleInventory,numberOfVehicles);
  81.                 break;
  82.             }
  83.         case 4:
  84.             {
  85.                 printStereos(vehicleInventory,numberOfVehicles);
  86.                 break;
  87.             }
  88.         case 5:
  89.             {
  90.                 printLeather(vehicleInventory,numberOfVehicles);
  91.                 break;
  92.             }
  93.         case 6:
  94.             {
  95.                 vehicle::sortByManufactureDate(vehicleInventory,numberOfVehicles);
  96.                 printAllVehicles(vehicleInventory,numberOfVehicles);
  97.                 break;
  98.             }
  99.         case 7:
  100.             {
  101.                 cout << "Exiting Program. " << endl;
  102.                 flag = false;
  103.                 break;
  104.             }
  105.         default:
  106.             {
  107.                 cout << "You have entered an invalid option: " << endl;
  108.                 break;
  109.             }
  110.         }
  111.     }
  112.     ///- end switch
  113.     return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement