Question: Looking for help with my code, It is currently running a vector but I want the main.cpp and the inventory.h and inventory.cpp to be running
Looking for help with my code, It is currently running a vector but I want the main.cpp and the inventory.h and inventory.cpp to be running a array over a vector, is there a way to make it a array over a vector? This is all in C coding format
Inventory.h part
#ifndef INVENTORYHINCLUDED
#define INVENTORYHINCLUDED
#include
#include "Car.h
#include "Truck.h
class Inventory This is the header for the inventory class which stores ve
private:
std::vector cars;
public:
Inventory;
~ Inventory;
void loadCarsconst std::string& sedanFile, const std::string& truckFile;
void searchByMakeconst std::string& make const;
void searchByModelconst std::string& model const;
void searchByPricedouble maxPrice const;
void searchByMilesint maxMiles const;
;
#endif INVENTORY.m INCLMLNED
Inventory.cpp part
#include
#include
#include
Inventory::Inventory This is the implementation of the Inventory.h class file and also opens and loads the Sedans and Trucks text files.
Inventory::~Inventory
for Car car : cars
delete car;
void Inventory::loadCarsconst std::string& sefanFile, const std::string& truckFile
loading sedans.
std::ifstream inFilesedanFile;
if inFile
std::string make, model, hybridStr;
double price;
int miles;
whileinFile make model price miles hybridStr
bool isHybrid hybridStr "yes";
cars.pushbacknew Carmake model, price, miles, isHybrid;
inFile.close;
loading trucks.
inFiles.opentruckFiles;
if inFile
std::string make, model, engine;
double price;
int miles;
while inFiles make model price miles engine
cars.pushbacknew Truckmake model, price, miles, engine;
inFile.close;
void Inventory::searchByMakeconst std::string& make const
for const Car car : cars
if cargetMake make
cardisplay;
std::cout n;
Main.cpp part
int main
Inventory inventory;
inventory.loadCarssedanstxt "trucks.txt;
int choice;
whiletrue
displayMenu
std::cout "Select Option"
std::cin choice;
if choice break;
std::string searchText;
double price;
int miles;
switch choice
case :
std::cout "Enter Search Make: ;
std::cin searchText;
inventory.searchByMakesearchText;
break;
case :
std::cout "Enter Search Model: ;
std::cin searchText;
inventory.searchByModelsearchText;
break;
case :
std::cout "Enter Maximum Price: ;
stdcin price;
inventory.searchByPriceprice;
break;
case :
std::cout "Enter Maximum Miles: ;
std::cin miles;
inventory.searchByMilesmiles;
break;
default:
std::cout "Invalid choice.
;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
