SHARE
TWEET

Untitled

a guest Dec 6th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <cstdlib>
  5. #include <string>
  6. #include "pch.h"
  7.  
  8. using namespace std;
  9.  
  10. struct car {
  11.     string carMM;
  12.     int carYear;
  13.     string carColor;
  14.     string carClass;
  15.     string carFuel;
  16.     float carPrice;
  17. };
  18.  
  19. class AutoDealer {
  20. private:
  21.     car arr[15];;   // array of car elements
  22.     int count = sizeof(arr) / sizeof(arr[0]);
  23. public:
  24.     AutoDealer() //constructor
  25.     {
  26.         count = 0;
  27.     }
  28.  
  29.     void readCarsFile()
  30.     {
  31.         ifstream carsFile("autoinfo.txt");
  32.         for (int i=0; i < 5){
  33.         getline(carsFile, carRecord.carMM);
  34.         carsFile >> carRecord.carYear;              //read into array?
  35.         carsFile >> carRecord.carColor;
  36.         carsFile >> carRecord.carClass;
  37.         carsFile >> carRecord.carFuelType;
  38.         carsFile >> carRecord.carPrice;
  39.         count += 1
  40.         i+=1
  41.         }
  42.  
  43.        
  44.  
  45.     }
  46.     int i=2
  47.     void inputCarsInfo()
  48.     {
  49.        
  50.         input = 0;
  51.         while (input != "no") {
  52.             cout << "Would you like to input a car into the system? (yes or no)";
  53.             cin >> input;
  54.             if (input = "yes") {
  55.                 cout << "Input Make and Model:";
  56.                 getline(cin, carRecord.carMakeAndModel);
  57.                 cout << "Input Year:";
  58.                 cin >> carRecord.carYear;
  59.                 cout << "Input Color:";                     //new struct appended to array at current count
  60.                 cin >> carRecord.carColor;
  61.                 cout << "Input Class:";
  62.                 cin >> carRecord.carClass;
  63.                 cout << "Input Fuel-Type:";
  64.                 cin >> carRecord.carFuelType;
  65.                 cout << "Input Price:";
  66.                 cin >> carRecord.carPrice;
  67.                 count += 1;
  68.             }
  69.         }
  70.     }
  71.     void searchCars()
  72.     {
  73.  
  74.     }
  75.  
  76.     void displayCars()
  77.     {
  78.         cout << "          LEXINGTON, KY AUT DEALER CAR INVENTORY"
  79.         cout << "MAKE AND MODEL     YEAR     COLOR     CLASS     FUEL TYPE     PRICE"
  80.         cout << carsArray[index].MakeAndModel >> carsArray[index].Year >> carsArray[index].Color >> carsArray[index].Class >> carsArray[index].FuelType >> carsArray[index].Price; //sumthin about format in thing
  81.     }
  82.  
  83.     void writeCarsFile()
  84.     {
  85.  
  86.     }
  87. };
  88.  
  89. int main() {
  90.     AutoDealer obj1;
  91.     obj1.readCarsFile();
  92.         cout << "Please choose one of the following options (1,2,3,4):"
  93.         cout << "1. Input Cars"
  94.         cout << "2. Display Cars"
  95.         cout << "3. Search Cars"
  96.         cout << "4. Exit"
  97.         cin >> i;
  98.     if (i=1) {
  99.         obj1.inputCarsInfo();
  100.     }if (i = 2) {
  101.         obj1.displayCars():
  102.     }if (i = 3) {
  103.         obj1.searchCars();
  104.     }if i(i = 4) {
  105.         obj1.writeCars();
  106.         cout << "Thank you!";
  107.         return 0;
  108.     }
  109. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top