Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The goal for this assignment is to create some classes for a warmup in my C++ class. I have successfully made the showroom class (somewhat...),

The goal for this assignment is to create some classes for a warmup in my C++ class. I have successfully made the showroom class (somewhat...), but for some reason my Vehicle vector is not working. Whenever I try to compile the code, I get an "undefined symbol" error. If you have any suggestions on how I could get this to work, please let me know.

Below is my main class, and the showroom class I made. If there is anything else you need just let me know. I used xCode.

/// Main.cpp ///

image text in transcribed

image text in transcribed

#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

}

else if (testNum == 5)

{

Showroom one("Room 1", 3);

one.AddVehicle(vehicles[1]);

one.AddVehicle(vehicles[3]);

one.AddVehicle(vehicles[5]);

cout

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

}

return 0;

}

/// Showroom. h ///

image text in transcribed

#include "Vehicle.h"

#include

#include

using namespace std;

class Showroom{

public:

Showroom (string name = "Unnamed Showroom", unsigned int capacity = 0);

vector GetVehicleList();

void AddVehicle(Vehicle& v);

void ShowInventory();

float GetInventoryValue();

string name;

vector vehicleList();

unsigned int capacity;

};

/// Showroom.cpp ///

image text in transcribed

//#include "Vehicle.h"

//#include "Vehicle.cpp"

#include "Showroom.h"

#include

#include

using namespace std;

vector Showroom :: GetVehicleList(){

return vehicleList();

};

void Showroom :: AddVehicle(Vehicle& v){

vehicleList().push_back(v);

};

void Showroom :: ShowInventory(){

for (int i = 0; i

vehicleList()[i].Display();

}

};

float Showroom :: GetInventoryValue(){

float value = 0.0;

float inventoryValue = 0;

for (int i = 0; i

inventoryValue += vehicleList()[i].GetPrice();

}

return inventoryValue;

return value;

};

1 #include "Vehicle.h" 2 #include "Showroom.h" 3 #include 4 #include 5 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 > testNum; if (testNum == 1) Showroom test Showroom; test Showroom. 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 4 #include using namespace std; class Showroom public: Showroom (string name = "Unnamed Showroom", unsigned int capacity = ); vector GetVehicleList(); void AddVehicle(Vehicle& v); void ShowInventory(); float Get InventoryValue(); string name; vector vehicleList(); unsigned int capacity; 18 }; 1 //#include "Vehicle.h" 2 //#include "Vehicle.cpp" 4 #include "Showroom.h" 5 #include 6 #include 7 using namespace std; 10 vector Showroom :: GetVehicleList() { return vehicleList(); 12 }; 13 void Showroom :: AddVehicle(Vehicle& v){ 14 vehicleList().push_back(v); 15 }; 16 void Showroom :: ShowInventory() { 17 for (int i = 0; i 4 #include 5 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 > testNum; if (testNum == 1) Showroom test Showroom; test Showroom. 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 4 #include using namespace std; class Showroom public: Showroom (string name = "Unnamed Showroom", unsigned int capacity = ); vector GetVehicleList(); void AddVehicle(Vehicle& v); void ShowInventory(); float Get InventoryValue(); string name; vector vehicleList(); unsigned int capacity; 18 }; 1 //#include "Vehicle.h" 2 //#include "Vehicle.cpp" 4 #include "Showroom.h" 5 #include 6 #include 7 using namespace std; 10 vector Showroom :: GetVehicleList() { return vehicleList(); 12 }; 13 void Showroom :: AddVehicle(Vehicle& v){ 14 vehicleList().push_back(v); 15 }; 16 void Showroom :: ShowInventory() { 17 for (int i = 0; i

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

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions

Question

What strategies might you use to support learning in English?

Answered: 1 week ago