Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include Vehicle.h using namespace std; int main ( ) { int input; cin > > input; if ( input = = 1

#include
#include
#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 vehicles;
// TODO: Add the three Vehicle objects to the vector using the push_back() function
vehicles.push_back(muscleCar);
vehicles.push_back(electric);
vehicles.push_back(suv);
// TODO: Print out each Vehicle by looping through the vector and calling the Display() function for each Vehicle object
for(int i =0; i < vehicles.size(); i++){
vehicles[i].Display();
}
return 0;
}
#include
#include
using namespace std;
class Vehicle {
private:
std::string make;
std::string model;
unsigned int year;
float price;
unsigned int mileage;
public:
Vehicle(){
make =COP3503;
model = "Rust Bucket";
year =1900;
price =0;
mileage =0;
}
};
/*class Showroom {
private:
std::string name;
std::vector vehicles;
int max_capacity;
public:
Showroom(std::string name, int max_capacity) : name(name), max_capacity(max_capacity){}
bool
}*/
#include Vehicle.h
#include
// Function definitions
Vehicle::Vehicle()
{
public:
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 Display(){
cout << year <<""<< make <<""<< model <<" $"<< price <<""<< mileage << endl;
}
string GetYearMakeModel(){
string str = to_string(year)+""+ make +""+ model;
retrun str;
}
float GetPrice(){
retrun 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 Javas 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 dont have to worry about the structure
of the program. Instead, you can focus solely on the structure of the classes and their interactions

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

13.3 Define and describe some of the barriers to seeking treatment.

Answered: 1 week ago

Question

4. How has e-commerce affected business-to-business transactions?

Answered: 1 week ago