Question: Need help with c++ HW. please post with different sections labeled: Vehicle.h, Vehicle.cpp, Showroom.h, Showroom.cpp, Showroom.h, and Showroom.cpp thanks! Here is the given Main.cpp function:
Need help with c++ HW. please post with different sections labeled: Vehicle.h, Vehicle.cpp, Showroom.h, Showroom.cpp, Showroom.h, and Showroom.cpp thanks!



![void TestOne(Vehicle vehicles[]); void TestTwo(Vehicle vehicles[]); void TestThree(Vehicle vehicles[]); void TestFour(Vehicle vehicles[]);](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66da1d0aeed6b_31466da1d0a61535.jpg)
![void TestFive(Vehicle vehicles[]); void TestSix(Vehicle vehicles[]); int main() { // Initialize some](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66da1d0bd1056_31566da1d0b401d3.jpg)
Here is the given Main.cpp function:
#include "Vehicle.h" #include "Showroom.h" #include "Dealership.h" #include
void TestOne(Vehicle vehicles[]); void TestTwo(Vehicle vehicles[]); void TestThree(Vehicle vehicles[]); void TestFour(Vehicle vehicles[]); void TestFive(Vehicle vehicles[]); void TestSix(Vehicle vehicles[]);
int main() { // Initialize some data. It's hard-coded here, but this data could come from a file, database, etc Vehicle vehicles[] = { Vehicle("Ford", "Mustang", 1973, 9500, 113000), Vehicle("Mazda", "CX-5", 2017, 24150, 5900), Vehicle("Dodge", "Charger", 2016, 18955, 9018), Vehicle("Tesla", "Model S", 2018, 74500, 31), Vehicle("Toyota", "Prius", 2015, 17819, 22987), Vehicle("Nissan", "Leaf", 2016, 12999, 16889), Vehicle("Chevrolet", "Volt", 2015, 16994, 12558), };
// Set the precision for showing prices with 2 decimal places cout
int testNum; cin >> testNum; if (testNum == 1) TestOne(vehicles); else if (testNum == 2) TestTwo(vehicles); else if (testNum == 3) TestThree(vehicles); else if (testNum == 4) TestFour(vehicles); else if (testNum == 5) TestFive(vehicles); else if (testNum == 6) TestSix(vehicles);
return 0; }
void TestOne(Vehicle vehicles[]) { Dealership testDealership; testDealership.ShowInventory(); }
void TestTwo(Vehicle vehicles[]) { // Showrooms to store the vehicles Showroom one("Test Room One", 3); one.AddVehicle(vehicles[2]); one.AddVehicle(vehicles[6]); //showroom.AddVehicle(&vehicles[2]);
Showroom two("Test Room Two", 4); two.AddVehicle(vehicles[1]); two.AddVehicle(vehicles[2]); two.AddVehicle(vehicles[3]);
// A "parent" object to store the Showrooms Dealership dealership("COP3503 Vehicle Emporium", 2); dealership.AddShowroom(one); dealership.AddShowroom(two);
dealership.ShowInventory(); }
void TestThree(Vehicle vehicles[]) { // Showrooms to store the vehicles Showroom one("Test Room One", 3); one.AddVehicle(vehicles[1]); one.AddVehicle(vehicles[2]); //showroom.AddVehicle(&vehicles[2]);
Showroom two("Test Room Two", 4); two.AddVehicle(vehicles[3]); two.AddVehicle(vehicles[4]); two.AddVehicle(vehicles[0]);
// A "parent" object to store the Showrooms Dealership dealership("COP3503 Vehicle Emporium", 2); dealership.AddShowroom(one); dealership.AddShowroom(two); // Should get an error message here dealership.AddShowroom(two);
dealership.ShowInventory(); }
void TestFour(Vehicle vehicles[]) { // Showrooms to store the vehicles Showroom showroom("Primary Showroom", 3); showroom.AddVehicle(vehicles[0]); showroom.AddVehicle(vehicles[1]); showroom.AddVehicle(vehicles[6]);
Showroom secondary("Fuel-Efficient Showroom", 4);
secondary.AddVehicle(vehicles[4]); secondary.AddVehicle(vehicles[5]);
Showroom third("Fuel-Efficient Showroom", 4); third.AddVehicle(vehicles[3]); third.AddVehicle(vehicles[3]); third.AddVehicle(vehicles[3]); // A "parent" object to store the Showrooms Dealership dealership("COP3503 Vehicle Emporium", 3); dealership.AddShowroom(showroom); dealership.AddShowroom(secondary); dealership.AddShowroom(third);
cout
void TestFive(Vehicle vehicles[]) { // Showrooms to store the vehicles Showroom showroom("Primary Showroom", 6); showroom.AddVehicle(vehicles[0]); showroom.AddVehicle(vehicles[1]); showroom.AddVehicle(vehicles[2]); showroom.AddVehicle(vehicles[3]); showroom.AddVehicle(vehicles[4]); showroom.AddVehicle(vehicles[5]);
Showroom secondary("Fuel-Efficient Showroom", 4);
secondary.AddVehicle(vehicles[4]); secondary.AddVehicle(vehicles[5]); secondary.AddVehicle(vehicles[5]);
Showroom third("Fuel-Efficient Showroom", 4); third.AddVehicle(vehicles[3]); third.AddVehicle(vehicles[4]); third.AddVehicle(vehicles[5]); third.AddVehicle(vehicles[6]); // A "parent" object to store the Showrooms Dealership dealership("COP3503 Vehicle Emporium", 3); dealership.AddShowroom(showroom); dealership.AddShowroom(secondary); dealership.AddShowroom(third);
cout
void TestSix(Vehicle vehicles[]) { // Showrooms to store the vehicles Showroom showroom("Primary Showroom", 4); showroom.AddVehicle(vehicles[2]); showroom.AddVehicle(vehicles[4]); showroom.AddVehicle(vehicles[6]);
Showroom third("Fuel-Efficient Showroom", 4); third.AddVehicle(vehicles[3]); third.AddVehicle(vehicles[5]); third.AddVehicle(vehicles[6]);
// A "parent" object to store the Showrooms Dealership dealership("COP3503 Vehicle Emporium", 3); dealership.AddShowroom(showroom); dealership.AddShowroom(third);
cout
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 - fundamentally the same as other languages - The std::vector class - similar to Java's ArrayList class, an expandable container - The std::string class - similar to strings everywhere - The const keyword - Mark things as constant, unchanging, or "read only" - Passing by reference (the \& character) 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 don't have to worry about the structure of the program. Instead, you can focus solely on the structure of the classes and their interactions. Vehicle The Vehicle class is the basic container of this assignment. You will need to store the following data as private data members of the class: - A std::string to store the make of the vehicle (such as Mazda, Toyota, etc) - A std::string to store the model of the vehicle (such as Mustang, Model S, F-150, etc) - An unsigned integer to store the year - A float to store the price - An unsigned integer to How many miles does the vehicle have on it? In addition to these data members, you should have the following public functions: // Default constructor, initializes variables to default values Vehicle(); Vehicle(string make, string model, int year, float price, int mileage); // Print out the vehicle's details in a single line: // 1973 Ford Mustang $9500113000 void Display() const; // Create and return a string in the form of "YEAR MAKE MODEL" // Example: "1970 Ford Mustang" string GetYearMakeModel() const; // Return the price float GetPrice() const; Default values and constructors While the definition of "appropriate defaults" may vary from one scenario to the next, for this assignment you can use these values as your defaults: [ These defaults are chosen arbitrarily for this assignment-for your own projects, you can of course choose anything that you like. Showroom The Showroom class is a bit more sophisticated. Its purpose is to store a collection of Vehicle objects. Each Showroom that you create could have a different number of Vehicles (depending on its size), so for this assignment we'll use a vector. Your Showroom should contain variables for the following: - The name of the Showroom - A vector to store Vehicle objects - A maximum capacity of the showroom (we don't want to add Vehicles beyond this limit) In addition, you should create the following functions: // Default constructor (all parameters have default values) Showroom(string name = "Unnamed Showroom", unsigned int capacity =0 ); // Accessor const vector\& GetVehicleList( ) const; // Behaviors void AddVehicle(const Vehicle\& v); void ShowInventory( ) const; Dealership The Dealership class in some ways is very similar to the Showroom. Instead of Vehicles, it will store a vector of Showroom objects. It will also need a name and a capacity. In addition, you will need functions: // Constructor Dealership(string name = "Generic Dealership", unsigned int capacity =0 ); // Behaviors void AddShowroom(const Showroom \&s); float GetAveragePrice() const; void ShowInventory() const; Relevant Reading zyBooks chapters: Strings Arrays / Vectors (specifically the section on vectors) Objects and Classes User-Defined Functions (specifically the section on Pass by Reference) Canvas->Pages->strings - a more in-depth look at strings Tips A few tips about this assignment: - You can print out a tab character (the escape sequence ' \t ) to help line up the output. - Don't try to tackle everything all at once. Work on one class at a time. Can't really have a Dealership without a Showroom, which really needs Vehicles... - An extension of that: work on one function, one class variable at a time. Create a constructor, initialize a single variable, test that out. When that works, move to the next part, and so on. Example Output Default constructor output 1900 COP3503 Rust Bucket $0.000 Unnamed Showroom is empty! Generic Dealership is empty! Average car price: $0.00 Showroom is full! Cannot add Dodge Caravan 1992 Vehicles in Example Showroom 2018 Bugatti Chiron $12447.004 2013 Chrysler Sebring $1819.0022987 Dealership output and error message when Dealership is full Dealership is full, can't add another showroom! Vehicles in Room One 1998 Dodge Neon \$500.00 932018 Vehicles in Room Two 2001 Ford Escort $2000.00125900 2004 Ford F-150 \$500.00 7392 Average car price: \$1000.00 Calling just the GetAveragePrice() function of the dealership Using just the GetAveragePrice() function Average price of the cars in the dealership: $19272.81
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
