Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include class Vehicle { protected: std::string brand; int capacity; public: Vehicle ( const std::string& brand, int capacity ) : brand ( brand ) ,

#include
#include
class Vehicle {
protected:
std::string brand;
int capacity;
public:
Vehicle(const std::string& brand, int capacity)
: brand(brand), capacity(capacity){}
virtual void move()=0;
};
class Car : public Vehicle {
private:
std::string model;
int year;
public:
Car(const std::string& brand, const std::string& model, int year)
: Vehicle(brand,5), model(model), year(year){}
void move() override {
std::cout << "Driving the car: "<< brand <<""<< model <<""<< year << std::endl;
}
};
class Train : public Vehicle {
private:
std::string name;
public:
Train(const std::string& name, int capacity)
: Vehicle("Train", capacity), name(name){}
void move() override {
std::cout << "The train "<< name <<" is running with a capacity of "<< capacity <<" passengers." << std::endl;
}
};
int main(){
Car myCar("Toyota", "Camry", 2020);
Train myTrain("Express",300);
myCar.move();
myTrain.move();
return 0;
}Please represent this code in UML

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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