For this assignment, you will be building a vehicle fleet management system usin
ID: 3731018 • Letter: F
Question
For this assignment, you will be building a vehicle fleet management system using object-oriented
programming techniques. Each problem will have you adding functionality to the fleet management system.
1. Create a Car class. A car should have a make (string), a model (string), and a VIN number (long). Create
a Boat class. A boat should have a name (string), and a cargo size (double). Create an Airplane class. An
airplane should have a manufacturer (string) and a serial number (long). Each class should also define a
void Status() function which prints out information about that object. Use the following main function
and make sure the output matches the expected output indicated by the comments.
int main()
{
Car car{ "Tesla", "S", 12345L };
Boat boat{ "Mayflower", 7.5 };
Airplane plane{ "Boeing", 98765L };
// (should print) Car: Make - Tesla, Model - S, VIN - 12345
car.Status();
// (should print) Boat: Name - Mayflower, Cargo - 7.5
boat.Status();
// (should print) Airplane: Manufacturer - Boeing, Serial - 98765
plane.Status();
}
Explanation / Answer
#include <iostream>
using namespace std;
class Car
{
private:
string make,model;
long VIN;
public:
Car(string make,string model,long VIN)//argument constructor
{
this->make = make;
this->model = model;
this->VIN = VIN;
}
void Status()
{
cout<<" Car: Make - "<<make<<", Model - "<<model<<", VIN - "<<VIN;
}
};
class Boat
{
private:
string name;
double cargoSize;
public:
Boat(string name,double cargoSize)//argument constructor
{
this->name = name;
this->cargoSize = cargoSize;
}
void Status()
{
cout<<" Boat: Name - "<<name<<", Cargo - "<<cargoSize;
}
};
class Airplane
{
private:
string manufacturer;
long serialNumber;
public:
Airplane(string manufacturer,long serialNumber)//argument constructor
{
this->manufacturer = manufacturer;
this->serialNumber = serialNumber;
}
void Status()
{
cout<<" Airplane: Manufacturer - "<<manufacturer<<", Serial - "<<serialNumber;
}
};
int main()
{
Car car{ "Tesla", "S", 12345L };
Boat boat{ "Mayflower", 7.5 };
Airplane plane{ "Boeing", 98765L };
// (should print) Car: Make - Tesla, Model - S, VIN - 12345
car.Status();
// (should print) Boat: Name - Mayflower, Cargo - 7.5
boat.Status();
// (should print) Airplane: Manufacturer - Boeing, Serial - 98765
plane.Status();
return 0;
}
Output:
Car: Make - Tesla, Model - S, VIN - 12345
Boat: Name - Mayflower, Cargo - 7.5
Airplane: Manufacturer - Boeing, Serial - 98765
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.