Home / Expert Answers / Computer Science / this-lab-has-3-parts-attached-is-the-default-template-which-needs-changing-along-with-the-main-cpp-pa478

(Solved): This lab has 3 parts. attached is the default template which needs changing along with the main.cpp ...



This lab has 3 parts. attached is the default template which needs changing along with the main.cpp which does not change.

Overview
The purpose of this assignment is give you some experience writing classes in \( \mathrm{C}++ \), the various speciaUniversity of Florid
// Default constructor, initializes variables to default values
Vehicle();
Vehicle(string make, string mThe Showroom class is a bit more sophisticated. Its purpose is to store a collection of Vehicle objects. Each Showroom that yDealership
The Dealership class in some ways is very similar to the Showroom. Instead of Vehicles, it will store a vector of Example Output
1900 COP3503 Rust Bucket \( \$ 0.000 \)
Unnamed Showroom is empty!
Generic Dealership is empty!
Average car prThe complete assignment description can be found on Canvas under the assignment Lab 2
Here youll just implement the basic

#include <iostream>
#include <vector>
#include "Vehicle.h"
using namespace std;

int main()
{
   int input;
   cin >> input;
   if (input == 1)
   {
      Vehicle defaultVehicle;
      defaultVehicle.Display();
   }
   else if (input == 2)
   {
      Vehicle customVehicle1("Tesla", "Model S", 2019, 46122, 42);
      customVehicle1.Display();
      Vehicle customVehicle2("Chrysler", "New Yorker", 1984, 2000, 100423);
      customVehicle2.Display();

   }
   else if (input == 3)
   {
      Vehicle customVehicle1("Chrysler", "New Yorker", 1984, 2000, 100423);
      Vehicle customVehicle2("COP3503", "Moped", 2019, 2200, 45);
      cout << "Price of the vehicles: $" << customVehicle1.GetPrice() + customVehicle2.GetPrice() << endl; 
      
   }
   else if (input == 4)
   {
      Vehicle customVehicle1("Razor", "Scooter", 2019, 39, 950);
      cout << customVehicle1.GetYearMakeModel();
   }
   else if (input == 5)
   {
      Vehicle muscleCar("Ford", "Mustang", 1968, 82550, 71000);
      Vehicle electric("Toyota", "Prius", 2014, 27377, 12);
      Vehicle suv("Mazda", "CX5", 2018, 28449, 11047);
      vector<Vehicle> vehicles;
      // TODO: Add the three Vehicle objects to the vector using the push_back() function

      // TODO: Print out each Vehicle by looping through the vector and calling the Display() function for each Vehicle object
   }
   return 0;
}

The next class youre going to write and test is the Showroom. This class will be storing Vehicle objects, so you can just br

// Main.cpp code (does not modify)

#include "Vehicle.h"
#include "Showroom.h"
#include <iostream>
#include <iomanip>
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 << std::fixed << std::setprecision(2);

    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 << "Total value: $" << one.GetInventoryValue();
    }
    else if (testNum == 5)
    {
      Showroom one("Room 1", 3);
       one.AddVehicle(vehicles[1]);
       one.AddVehicle(vehicles[3]);
       one.AddVehicle(vehicles[5]);

       cout << "Total value: $" << one.GetInventoryValue() << endl;
       
      Showroom two("Room 2", 6);
       two.AddVehicle(vehicles[6]);
       two.AddVehicle(vehicles[5]);
       two.AddVehicle(vehicles[4]);
       two.AddVehicle(vehicles[3]);
       two.AddVehicle(vehicles[2]);
       two.AddVehicle(vehicles[1]);
       
       cout << "Total value: $" << two.GetInventoryValue();
       
    }

   return 0;    
}

In this part you will write the final class, the Dealership. This classes utilizes both the Showroom and Vehicle class, so be

//main.cpp (code does not alter)

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

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 << 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);

   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 << "Average price of the cars in the dealership: $" << 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(secondary);
    dealership.AddShowroom(third);

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

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 << "Average price of the cars in the dealership: $" << dealership.GetAveragePrice();
}

Overview The purpose of this assignment is give you some experience writing classes in \( \mathrm{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 In addition to these data members, you should have the following public functions: University of Florid // 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. 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(); Function Reference 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 'It' ) 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 1900 COP3503 Rust Bucket \( \$ 0.000 \) Unnamed Showroom is empty! Generic Dealership is empty! Average car price: \( \$ 0.00 \) Showroom output and error message when Showroom is full 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.00125900 \) 2004 Ford \( F-150 \$ 500.007392 \) 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 \) The complete assignment description can be found on Canvas under the assignment "Lab 2" Here you'll just implement the basic Vehicle class and its functions. The class declaration will be written in Vehicle.h, while the definitions of the functions will be written in Vehicle.cpp. Tests 1 and 2 are set up for you; you just need to write the Vehicle class for those. For test 3, you will have to fill in the sections that are marked with a // TODO comment. \( 416902.2358504 .9 \times 379 y 7 \) \begin{tabular}{l|l} LAB & 21.2.1: Lab 2-Classes Part 1 \end{tabular} \( 0 / 5 \) 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. \( 416902.2358504 .0 \times 3 z q y 7 \) Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. 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. Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box.


We have an Answer from Expert

View Expert Answer

Expert Answer


Answer For your requirements i have provided the indetail note:- as per chegg rules and regulations i have answered the question.(minimum no.of question this is the answer for ur question Step by step :- Vehicle.h #include #include
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe