Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. class Lights
  2. {
  3. public:
  4.     enum Elo
  5.     {
  6.         c1 = 1,
  7.         c2 = 2,
  8.         c3 = 3,
  9.         c4 = 4
  10.     };
  11.     bool red() const
  12.     {
  13.         return redLight;
  14.     }
  15.     bool yellow() const
  16.     {
  17.         return yellowLight;
  18.     }
  19.     bool green() const
  20.     {
  21.         return greenLight;
  22.     }
  23.     void flip()
  24.     {
  25.         switch (lightSwitch)
  26.         {
  27.         case c1:
  28.             redLight = true; yellowLight = true; greenLight = false;
  29.             lightSwitch = c2;
  30.             break;
  31.         case c2:
  32.             redLight = false; yellowLight = false; greenLight = true;
  33.             lightSwitch = c3;
  34.             break;
  35.         case c3:
  36.             redLight = false; yellowLight = true; greenLight = false;
  37.             lightSwitch = c4;
  38.             break;
  39.         case c4:
  40.             redLight = true; yellowLight = false; greenLight = false;
  41.             lightSwitch = c1;
  42.             break;
  43.         default:
  44.             break;
  45.         }
  46.     }
  47. private:
  48.     bool yellowLight = false;
  49.     bool greenLight = false;
  50.     bool redLight = true;
  51.     int lightSwitch = 1;
  52. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement