blob: a023979b3a270f01f86a59c593874e9c9de1a84c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include "Truck.h"
#include "Vehicle.h"
Truck::Truck(String brand, unsigned maxSpeed) : Vehicle(brand, (maxSpeed >= 80 && maxSpeed <= 140) ? maxSpeed : 80)
{}
unsigned Truck::getSpeedOnRoad(Road road) const {
switch (road) {
case Speedy: return Vehicle::getMaxSpeed() / 4;
case ThirdClass: return 10;
case Highway: return Vehicle::getMaxSpeed() / 2;
}
return Vehicle::getMaxSpeed();
}
Truck* Truck::clone() const {
return new Truck(*this);
}
|