Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi. I need help on my C++ homework. I just need help on Part 3 of this assignment. I've also already finished VEHICLE.H, SHOWROOM.H, and

Hi. I need help on my C++ homework. I just need help on Part 3 of this assignment. I've also already finished VEHICLE.H, SHOWROOM.H, and DEALERSHIP.H which you can find at the very bottom.

*****I now need help with getting code for DEALERSHIP.CPP, VEHICLE.CPP, and SHOWROOM.CPP ONLY*****

Last thing, can you make the code organized too if you can?

Thanks for the help!

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

INSTRUCTIONS:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ALL THE .H CODE THATS FINISHED (I NEED CODE HELP FOR DEALERSHIP.CPP, VEHICLE.CPP, and SHOWROOM.CPP NOT THE CODE SHOWN BELOW, BUT PLEASE USE IT AS REFERENCE IF YOU WOULD LIKE):

#include  #include  #include  #include  using namespace std; ---VEHICLE.H---- class Vehicle { // Data member to store Vehicle information string make; string model; int year; float price; unsigned int mileage; public: // Default constructor definition Vehicle() { make = "COP3503"; model = "Rust Bucket"; year = 1900; price = 0.0 f; mileage = 0; } // End of constructor // Parameterized constructor to assign parameter values to data member Vehicle(string make, string model, int year, float price, int mileage) { this -> make = make; this -> model = model; this -> year = year; this -> price = price; this -> mileage = mileage; } // End of constructor // Function to display Vehicle information void Display() { cout ---SHOWROOM.H---- // Defines a class Showroom class Showroom { // Data member to store Showroom information string name; vector  vehicleList; int capacity; int numberOfVehicle; public: // Parameterized constructor to assign parameter values to data member Showroom(string name = "Unnamed Showroom", unsigned int capacity = 0) { this -> name = name; this -> capacity = capacity; numberOfVehicle = 0; } // End of constructor // Function to return vehicle list const vector  & GetVehicleList() const { return vehicleList; } // End of function // Function to add a vehicle to showroom void AddVehicle(const Vehicle & v) { // Checks if number of vehicles in showroom is equal to maximum capacity // display error message if (numberOfVehicle == capacity) cout ---DEALERSHIP.H---- // Defines a class Dealership class Dealership { // Data member to store Dealership information string name; vector  showroomList; int capacity; int numberOfShowrooms; public: // Parameterized constructor to assign parameter values to data member Dealership(string name = "Generic Dealership", unsigned int capacity = 0) { this -> name = name; this -> capacity = capacity; numberOfShowrooms = 0; } // End of constructor // Function to add a showroom to dealer void AddShowroom(const Showroom & s) { // Checks if number of showrooms is equals to maximum capacity // Displays error message if (numberOfShowrooms == capacity) cout  vl = showroomList[c].GetVehicleList(); // Loops till number of vehicles for (int d = 0; d  

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

HERE IS VECHILE.CPP FOR REFERENCE:

#include "Vehicle.h"

Vehicle::Vehicle() {

make = "COP3503" ; model = "Rust Bucket"; year = 1900; price = 0; mileage = 0; }

Vehicle::Vehicle(string 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 Vehicle::Display() { std::cout

}

string Vehicle::GetYearMakeModel() { string yearMakeModel = ""; yearMakeModel = to_string(year) + " " + make + " " + model;

return yearMakeModel; }

float Vehicle::GetPrice() { return 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 Java's 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 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 store the number of miles the vehicle has been driven // 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(); // create and return a string in the form of "YEAR MAKE MODEL" // Example: "1970 Ford Mustang" string GetYearMakeModel(); // Return the price float GetPrice(); 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 vector GetVehicleList(); // Behaviors void AddVehicle(Vehicle v); void ShowInventory( ); float GetInventoryValue(); 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(Showroom s); float GetAveragePrice(); void ShowInventory(); 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 constructoroutput 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.00 4 2013 Chrysler Sebring $1819.00 22987 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.00 125900 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 In this part you will write the final class, the Dealership. This classes utilizes both the Showroom and Vehicle class, so be sure to have those completed first. main.cpp is provided for you. is marked as read only Current file: main.cpp - \begin{tabular}{l|l} \#include "Vehicle.h" & main.cpp \\ \#include "Showroom.h" & \\ \#include "Dealership.h" & Vehicle.h \\ \#include & \\ \#include & Showroom.h \\ using namespace std; & \\ void TestOne(Vehicle vehicles[]); & Vehicle.cpp \\ void TestTwo(Vehicle vehicles[]); & \\ void TestThree(Vehicle vehicles[]); & Dealership.h \\ void TestFour(Vehicle vehicles[]); & \\ void TestFive(Vehicle vehicles[]); & Dealership.cpp \\ void TestSix(Vehicle vehicles[]); & \\ \hline intmain(){Showroom.cpp \end{tabular} // 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 std:: fixed std: : setprecision(2); 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); 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 "Average price of the cars in the dealership: \( \$ " \ll \)quot;quot;quot; dealership.GetAveragePrice(); 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(secondarv): 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 "Average price of the cars in the dealership: \( \$ " \ll \) dealership.GetAveragePrice(); 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(secondarv): 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 "Average price of the cars in the dealership: \( \$ " \ll \) dealership.GetAveragePrice(); 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(secondarv)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

10. Describe a geo-visual database.

Answered: 1 week ago

Question

Identify examples of loaded language and ambiguous language.

Answered: 1 week ago