forked from ashishps1/awesome-low-level-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicle.cpp
More file actions
20 lines (17 loc) · 796 Bytes
/
Vehicle.cpp
File metadata and controls
20 lines (17 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "Vehicle.hpp"
#include <iostream>
Vehicle::Vehicle(std::string licensePlate, VehicleType type, std::string color)
: licensePlate(licensePlate), type(type), color(color) {}
std::string Vehicle::getLicensePlate() const { return licensePlate; }
VehicleType Vehicle::getType() const { return type; }
std::string Vehicle::getColor() const { return color; }
void Vehicle::displayInfo() const {
std::cout << "Vehicle: " << color << " ";
switch (type) {
case VehicleType::CAR: std::cout << "Car"; break;
case VehicleType::MOTORCYCLE: std::cout << "Motorcycle"; break;
case VehicleType::TRUCK: std::cout << "Truck"; break;
case VehicleType::BUS: std::cout << "Bus"; break;
}
std::cout << " (License: " << licensePlate << ")" << std::endl;
}