Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <cstdlib>
- #include <string>
- #include "pch.h"
- using namespace std;
- struct car {
- string carMM;
- int carYear;
- string carColor;
- string carClass;
- string carFuel;
- float carPrice;
- };
- class AutoDealer {
- private:
- car arr[15];; // array of car elements
- int count = sizeof(arr) / sizeof(arr[0]);
- public:
- AutoDealer() //constructor
- {
- count = 0;
- }
- void readCarsFile()
- {
- ifstream carsFile("autoinfo.txt");
- for (int i=0; i < 5){
- getline(carsFile, carRecord.carMM);
- carsFile >> carRecord.carYear; //read into array?
- carsFile >> carRecord.carColor;
- carsFile >> carRecord.carClass;
- carsFile >> carRecord.carFuelType;
- carsFile >> carRecord.carPrice;
- count += 1
- i+=1
- }
- }
- int i=2
- void inputCarsInfo()
- {
- input = 0;
- while (input != "no") {
- cout << "Would you like to input a car into the system? (yes or no)";
- cin >> input;
- if (input = "yes") {
- cout << "Input Make and Model:";
- getline(cin, carRecord.carMakeAndModel);
- cout << "Input Year:";
- cin >> carRecord.carYear;
- cout << "Input Color:"; //new struct appended to array at current count
- cin >> carRecord.carColor;
- cout << "Input Class:";
- cin >> carRecord.carClass;
- cout << "Input Fuel-Type:";
- cin >> carRecord.carFuelType;
- cout << "Input Price:";
- cin >> carRecord.carPrice;
- count += 1;
- }
- }
- }
- void searchCars()
- {
- }
- void displayCars()
- {
- cout << " LEXINGTON, KY AUT DEALER CAR INVENTORY"
- cout << "MAKE AND MODEL YEAR COLOR CLASS FUEL TYPE PRICE"
- cout << carsArray[index].MakeAndModel >> carsArray[index].Year >> carsArray[index].Color >> carsArray[index].Class >> carsArray[index].FuelType >> carsArray[index].Price; //sumthin about format in thing
- }
- void writeCarsFile()
- {
- }
- };
- int main() {
- AutoDealer obj1;
- obj1.readCarsFile();
- cout << "Please choose one of the following options (1,2,3,4):"
- cout << "1. Input Cars"
- cout << "2. Display Cars"
- cout << "3. Search Cars"
- cout << "4. Exit"
- cin >> i;
- if (i=1) {
- obj1.inputCarsInfo();
- }if (i = 2) {
- obj1.displayCars():
- }if (i = 3) {
- obj1.searchCars();
- }if i(i = 4) {
- obj1.writeCars();
- cout << "Thank you!";
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement