klips/cpp/patterns/state/main.cpp

32 lines
600 B
C++
Raw Normal View History

2021-05-11 22:53:16 +00:00
#include <iostream>
#include "state.hpp"
int main(const int argc, const char * argv[]) {
Car * testCar = new Car;
testCar->report();
// Test transition from Stopped->Running
testCar->Start();
testCar->report();
// Test transition from Running->Stopped
testCar->Stop();
testCar->report();
// Test transition from Stopped->Broken
testCar->Smash();
testCar->report();
std::cout << "\nTesting burning state...\n";
Car *newCar = new Car;
newCar->report();
// Test transition from Stopped->Running->Burning
newCar->Start();
newCar->Smash();
newCar->report();
}