Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need part 2 of the lab. I already have and am providing main.cpp, Vehicle.h, Vehicle.cpp & Showroom.h //main.cpp #include Vehicle.h #include Showroom.h #include #include

I need part 2 of the lab.

image text in transcribed

image text in transcribed

I already have and am providing main.cpp, Vehicle.h, Vehicle.cpp & Showroom.h

//main.cpp #include "Vehicle.h" #include "Showroom.h" #include #include using namespace std;

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) { Showroom testShowroom; testShowroom.ShowInventory(); } else if (testNum == 2) { Showroom one("Small Showroom", 2); one.AddVehicle(vehicles[3]); one.AddVehicle(vehicles[5]);

one.ShowInventory(); } else if (testNum == 3) { Showroom one("Full Showroom", 2); one.AddVehicle(vehicles[0]); one.AddVehicle(vehicles[3]); one.AddVehicle(vehicles[5]);

one.ShowInventory(); } else if (testNum == 4) { Showroom one("Price Test", 3); one.AddVehicle(vehicles[2]); one.AddVehicle(vehicles[4]); one.AddVehicle(vehicles[6]);

cout

cout

return 0; }

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

//Vehicle.h #ifndef VEHICLE_H #define VEHICLE_H #include using namespace std;

class Vehicle { private: string make; string model; unsigned int year; float price; unsigned int mileage; public: Vehicle(); Vehicle(string make, string model, int year, float price, int mileage); void Display(); string GetYearMakeModel(); float GetPrice(); };

#endif

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

//Vehicle.cpp #include "Vehicle.h" #include #include using namespace std;

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 stats = ""; stats = to_string(year) + " " + make + " " + model; return stats; }

float Vehicle::GetPrice() { return price; }

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

Showroom.h

#include #include using namespace std; class Showroom{ string name; vector vehicles; int capacity; public: Showroom(){ name="Unnamed Showroom"; capacity=0; } Showroom(string name, unsigned int capaciy){ this->name=name; this->capacity=capaciy; } vector GetVehicleList(){ return vehicles; } void AddVehicle(Vehicle v){ int numberOfVehicles=vehicles.size(); if(numberOfVehicles==capacity){ cout

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

I just need Showroom.cpp, please don't copy from other answers on Chegg, have it work for the code I provided, preferably without editing said code, and also preferably explaining how their code works.

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 - ); // Accessor vector GetVehiclelist(); // Behaviors void Addvehicle(Vehicle v); void showInventory(); float Get InventoryValue(); Function Reference Constructor Same as all constructors! Initialize class member variables GetVehicleList Return the vector objects, so other code can access it AddVehicle If the Showroom is already full (numberOfvehicles == capacity), then you should print out "Showroom is full! Cannot add 2015 Mazda Miata" (this will use the GetYear Make Model() function from the Vehicle class) If there is space in the showroom, add the pass-in Vehicle to the class' vector. Vector objects can be expanded with the push_back() function. Showinventory Show all vehicles in the showroom, using the Display function of each vehicle GetinventoryValue Sum up the prices of all vehicles in the showroom and return that value 21.3 Lab 2 - Classes Part 2 The next class you're going to write and test is the Showroom. This class will be storing Vehicle objects, so you can just bring in your code from Part 1 and reuse that here. 3512742212470.py LAB ACTIVITY 21.3.1: Lab 2 - Classes Part 2 0/10 File is marked as read only Current file: main.cpp - 1 #include "Vehicle.h" 2 #include "Showroom.h" 3 #include 4 #include 5 using namespace std; 6 7 int main() 33 9 // Initialize some data. It's hard-coded here, but this data could come from a file, database, etc 10 Vehicle vehicles[] = 11 1 12 Vehicle("Ford", "Mustang", 1973, 9500, 113000), 13 Vehicle ("Mazda", "CX-5", 2017, 24150, 5900), 14 Vehicle("Dodge", "Charger", 2016, 18955, 9918), 15 Vehicle "Tesla", "Model S", 2018, 74500, 31), 16 Vehicle("Toyota", "Prius", 2015, 17819, 22987), 17 Vehicle("Nissan", "Leaf", 2016, 12999, 16889),

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

Step: 3

blur-text-image

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 Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

What are the need and importance of training ?

Answered: 1 week ago

Question

What is job rotation ?

Answered: 1 week ago