forked from coders-school/Cars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
28 lines (25 loc) · 812 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "PetrolCar.hpp"
#include "ElectricCar.hpp"
#include "HybridCar.hpp"
#include <iostream>
int main()
{
std::cout << std::endl << "OPEL" << std::endl;
PetrolCar opel(new PetrolEngine(120, 1800, 6));
opel.accelerate(50);
opel.brake();
opel.accelerate(-900);
opel.refuel();
std::cout << std::endl << "NISSAN" << std::endl;
ElectricCar nissan(new ElectricEngine(130, 650));
nissan.charge();
nissan.accelerate(80);
nissan.engine_ = new ElectricEngine(150, 700); // Changing an engine during driving is not safe
nissan.turnLeft();
std::cout << std::endl << "TOYOTA" << std::endl;
HybridCar toyota(new PetrolEngine(80, 1400, 5), new ElectricEngine(100, 540));
toyota.accelerate(100);
toyota.brake();
toyota.charge();
toyota.refuel();
}