Question: Not sure if my code is correct and numbers placed correctly. #include #include #include namespace sdds { class CarInventory { char * m _ type;
Not sure if my code is correct and numbers placed correctly.
#include
#include
#include
namespace sdds
class CarInventory
char mtype;
char mbrand;
char mmodel;
int myear;
int mcode;
double mprice;
void resetInfo
delete mtype;
delete mbrand;
delete mmodel;
mtype nullptr;
mbrand nullptr;
mmodel nullptr;
myear ;
mcode ;
mprice ;
public:
CarInventory : mtypenullptr mbrandnullptr mmodelnullptr myear mcode mprice
resetInfo;
CarInventoryconst char type, const char brand, const char model, int year int code double price
: mtypenullptr mbrandnullptr mmodelnullptr myear mcode mprice
resetInfo;
if type && brand && model
mtype new charstrlentype;
mbrand new charstrlenbrand;
mmodel new charstrlenmodel;
strcpymtype, type;
strcpymbrand, brand;
strcpymmodel, model;
if year myear year;
if code && code mcode code;
if price mprice price;
~CarInventory
resetInfo;
CarInventory& setInfoconst char type, const char brand, const char model, int year, int code, double price
resetInfo;
if type && brand && model
mtype new charstrlentype;
mbrand new charstrlenbrand;
mmodel new charstrlenmodel;
strcpymtype, type;
strcpymbrand, brand;
strcpymmodel, model;
if year myear year;
if code && code mcode code;
if price mprice price;
return this;
void printInfo const
std::cout std::setw mtype std::setw mbrand std::setw mmodel
std::setw myear std::setw mcode std::setw std::fixed std::setprecision
mprice std::endl;
bool isValid const
return mtype && mbrand && mmodel && myear && mcode && mcode && mprice ;
bool isSimilarToconst CarInventory& car const
return strcmpmtype, car.mtype && strcmpmbrand, car.mbrand && myear car.myear;
;
bool findsimilarCarInventory car const int numcars
for int i ; i numcars; i
for int j i ; j numcars; j
if cariisSimilarTocarj
return true;
return false;
int main
const int numcars ;
bool invaliddata false;
sdds::CarInventory carsnumcars
Acura "integra",
Alfa Romeo", "Giulia",
CadillacCT
Chevorlet "Bolt",
Dodge "Hornet",
HondaCRV
Hyundai "Santa Fe
InfinitiQ
Kia "Carnival",
;
if carssetInfoisValid
std::cout "Information was set correctly!" std::endl;
else
std::cout "Information was set incorrectly!" std::endl;
if carssetInfoisValid
std::cout "Information was set correctly!" std::endl;
else
std::cout "Information was set incorrectly!" std::endl;
std::cout std::setw Car Inventory Information std::endl
std::endl;
std::cout Type Brand Model Year Code Price std::endl;
std::cout std::endl;
for int i ; i numcars; i
if carsiisValid
carsiprintInfo;
else
invaliddata true;
if invaliddata
std::cout std::endl;
File Edit Format View Help
Rental Car Inventory Program Algorithm:
Function: Greet the Reservation Agent.
At program start, display greeting message.
Function: User Menu
View inventory
Add new car to inventory
Rent car to customer
Process returned vehicle
Remove discontinued car from inventory
Quit
Function: View inventory
Display car inventory
Display User Menu again
Function: Add new car to inventory
Prompt Reservation Agent to enter new car info
Give the Reservation Agent the option to return to User Menu in case they change their mind
Display provided car info for Reservation Agent verification
If the information is incorrect
Return to the first prompt in this function
If the information is correct
Check if the car is in current inventory
If the car is already in inventory
Do not add the car
Inform the Reservation Agent that the car is already in inventory and cannot be accepted
File Edit Format View Help
Inform the Reservation Agent that the car is already in inventory and cannot be accepted
Display User Menu again
If the car is not in inventory
Add the car
Update inventory
Display User Menu again
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
