Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Lights
- {
- public:
- enum Elo
- {
- c1 = 1,
- c2 = 2,
- c3 = 3,
- c4 = 4
- };
- bool red() const
- {
- return redLight;
- }
- bool yellow() const
- {
- return yellowLight;
- }
- bool green() const
- {
- return greenLight;
- }
- void flip()
- {
- switch (lightSwitch)
- {
- case c1:
- redLight = true; yellowLight = true; greenLight = false;
- lightSwitch = c2;
- break;
- case c2:
- redLight = false; yellowLight = false; greenLight = true;
- lightSwitch = c3;
- break;
- case c3:
- redLight = false; yellowLight = true; greenLight = false;
- lightSwitch = c4;
- break;
- case c4:
- redLight = true; yellowLight = false; greenLight = false;
- lightSwitch = c1;
- break;
- default:
- break;
- }
- }
- private:
- bool yellowLight = false;
- bool greenLight = false;
- bool redLight = true;
- int lightSwitch = 1;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement