Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include Vehicle.h using namespace std; int main ( ) { int input; cin > > input; if ( input = = 1
#include
#include
#include "Vehicle.h
using namespace std;
int main
int input;
cin input;
if input
Vehicle defaultVehicle;
defaultVehicle.Display;
else if input
Vehicle customVehicleTesla "Model S;
customVehicleDisplay;
Vehicle customVehicleChrysler "New Yorker", ;
customVehicleDisplay;
else if input
Vehicle customVehicleChrysler "New Yorker", ;
Vehicle customVehicleCOP "Moped", ;
cout "Price of the vehicles: $ customVehicleGetPrice customVehicleGetPrice endl;
else if input
Vehicle customVehicleRazor "Scooter", ;
cout customVehicleGetYearMakeModel;
else if input
Vehicle muscleCarFord "Mustang", ;
Vehicle electricToyota "Prius", ;
Vehicle suvMazdaCX;
vector vehicles;
TODO: Add the three Vehicle objects to the vector using the pushback function
vehicles.pushbackmuscleCar;
vehicles.pushbackelectric;
vehicles.pushbacksuv;
TODO: Print out each Vehicle by looping through the vector and calling the Display function for each Vehicle object
forint i ; i vehicles.size; i
vehiclesiDisplay;
return ;
#include
#include
using namespace std;
class Vehicle
private:
std::string make;
std::string model;
unsigned int year;
float price;
unsigned int mileage;
public:
Vehicle
make COP;
model "Rust Bucket";
year ;
price ;
mileage ;
;
class Showroom
private:
std::string name;
std::vector vehicles;
int maxcapacity;
public:
Showroomstd::string name, int maxcapacity : namename maxcapacitymaxcapacity
bool
#include Vehicle.h
#include
Function definitions
Vehicle::Vehicle
public:
Vehicle;
Vehiclestring make, string model, int year, float price, int mileage;
this make make;
this model model;
this year year;
this price price;
this mileage mileage
void Display
cout year make model $ price mileage endl;
string GetYearMakeModel
string str tostringyear make model;
retrun str;
float GetPrice
retrun price;
;
Overview
The purpose of this assignment is give you some experience writing classes in C the various special
functions they make use of such as copy constructors, assignment operators, and destructors as well
as an introduction to dynamically allocating memory within those classes.
New Keywords Language concepts
Classes conceptually similar to other languages
The std::vector class similar to Javas ArrayList class, an expandable container
The std::string class similar in many ways to strings in most every language
Description
This program will represent a hypothetical car dealership, which consists of showrooms that contain the
vehicles for sale. To that end, there are three classes you will be writing:
Vehicle
Showroom
Dealership
For this assignment, main.cpp will be provided for you, so you dont have to worry about the structure
of the program. Instead, you can focus solely on the structure of the classes and their interactions
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started