Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

And main: #include \"Vehicle.h\" #include \"Showroom.h\" #include \"Dealership.h

ID: 3745259 • Letter: A

Question

And main:

#include "Vehicle.h"
#include "Showroom.h"
#include "Dealership.h"
#include <iostream>
#include <limits>
#include <memory>
#include <iomanip>
using namespace std;

void TestOne(Vehicle *v);
void TestTwo(Vehicle *v);

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("Telsa", "Model S", 2018, 74500, 31),
       Vehicle("Toyota", "Prius", 2015, 17819, 22987),
       Vehicle("Nissan", "Leaf", 2016, 12999, 16889),
       Vehicle("Chevrolet", "Volt", 2015, 16994, 12558),
   };

int testNum;
cin >> testNum;

if (testNum == 1)
TestOne(vehicles);
else if (testNum == 2)
TestTwo(vehicles);

   return 0;
}

void TestOne(Vehicle *vehicles)
{
// Showrooms to store the vehicles
   Showroom showroom("Primary Showroom", 3);
   showroom.AddVehicle(&vehicles[0]);
   showroom.AddVehicle(&vehicles[1]);
   //showroom.AddVehicle(&vehicles[2]);
  
   Showroom secondary("Fuel-Efficient Showroom", 4);
   secondary.AddVehicle(&vehicles[3]);
   secondary.AddVehicle(&vehicles[4]);
   secondary.AddVehicle(&vehicles[5]);
   secondary.AddVehicle(&vehicles[6]);

   // A "parent" object to store the Showrooms
   Dealership dealership("COP3503 Vehicle Emporium", 2);
   dealership.AddShowroom(&showroom);
   dealership.AddShowroom(&secondary);

   dealership.ShowInventory();
}

void TestTwo(Vehicle *vehicles)
{
   // Showrooms to store the vehicles
   Showroom showroom("Primary Showroom", 3);
   showroom.AddVehicle(&vehicles[0]);
   showroom.AddVehicle(&vehicles[1]);
  
   Showroom secondary("Fuel-Efficient Showroom", 4);

   secondary.AddVehicle(&vehicles[4]);
   secondary.AddVehicle(&vehicles[5]);
  
   Showroom third("Fuel-Efficient Showroom", 4);
   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 << "Using just the GetAveragePrice() function ";

   cout << "Average price of the cars in the dealership: $" << std::fixed << std::setprecision(2);
   cout << dealership.GetAveragePrice();
}

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: . The make of the vehicle (such as Mazda, Toyota, etc) . The model of the vehicle (such as Mustang, Model S, F-150, etc) The year The price . How many miles does the vehicle have on it? In addition to a constructor which takes in the necessary information, you will also need the following functions defined. If you are using dynamic memory in your class, you will also want to define a destructor, in which you will clean up (delete) any memory which was allocated by the class. Print all the information on a single line void Display() const; // Return a string in the form of "1970 Ford Mustang" string GetYearMakeModel() const; // How much to buy this? float GetPrice() const;

Explanation / Answer

// vehicle.h

#include<iostream>

#include<bits/stdc++.h>

class Vehicle

{

public:

string make;

string model;

int year;

float price;

int miles;

Vehicle(string s1,string s2,int x,int y,int z)

{

make = s1;

model = s2;

year = x;

price = y;

miles = z;

}

void Display()

{

cout<<year<<" "<<make<<" "<<model<<" "<<miles;

}

string GetYearMakeModel()

{

string s = to_string(year) + " " + make + " " + model;

}

float GetPrice()

{

return price;

}

};

// showroom.h

string name;

Vehicle **v;

int size;

int count;

Showroom(string s1,Vehicle **a,int x,int y)

{

name = s1;

v = new Vehicle[size];

for(int i = 0;i<size;i++)

{

v[i] = a[i];

}

size = x;

count = y;

}

void AddVehicle(Vehicle *a)

{

v[count-1] = a;

}

void ShowInventory()

{

cout<<name;

for(int i = 0;i<count;i++)

{

v[i].Display();

}

}

unsigned int GetCapacity()

{

unsigned int x = size;

return x;

}

unsigned int GetCount()

{

unsigned int y = count;

return y;

}

char * GetName()

{

char* a = name.c_str();

}

};

// dealership.h

#include<iostream>

#include<bits/stdc++.h>

#include<Vehicle.h>

#include<Showroom.h>

class Dealership

{

string name;

Showroom **v;

int size;

int count;

Dealership(string s1,Vehicle **a,int x,int y)

{

name = s1;

v = new Showroom[size];

for(int i = 0;i<size;i++)

{

v[i] = a[i];

}

size = x;

count = y;

}

void AddShowroom(Showroom *a)

{

v[count-1] = a;

}

void ShowInventory()

{

cout<<name;

for(int i = 0;i<count;i++)

{

v[i].ShowInventory();

}

}

unsigned int GetCapacity()

{

unsigned int x = size;

return x;

}

unsigned int GetCount()

{

unsigned int y = count;

return y;

}

char * GetName()

{

char* a = name.c_str();

}

};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote