Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef SEMAFOR_HPP_INCLUDED
- #define SEMAFOR_HPP_INCLUDED
- enum States { sOFF, sON, sBLINK, sOUT};
- enum Colors { cNONE, cBLINK, cRED, cYELLOWRED, cYELLOW, cGREEN}
- class Semafor
- {
- private:
- States state;
- Colors color;
- public:
- Semafor () { state=sOFF; color=sNONE}
- enum getSTATE () { return state }
- enum getCOLOR () { return color }
- bool turnON ();
- bool turnOFF ();
- bool turnBLINK ();
- bool turnOUT ();
- bool repair ();
- bool changeCOLOR ();
- }
- #endif // SEMAFOR_HPP_INCLUDED
- #include <iostream>
- #include "semafor.hpp"
- usnig namespace std;
- bool Semafor::turnON()
- {
- if (state=sOFF)
- {
- state=sON;
- color=cRED;
- return true;
- }
- else return false;
- }
- bool Semafor::turnOFF()
- {
- if (state=sON)
- {
- state=sOF;
- color=cNONE;
- return true;
- }
- else if (state=sBLINK)
- {
- state=sOFF;
- color=cBLINK;
- return true;
- }
- else return false;
- }
- bool Semafor::turnBLINK()
- {
- if (state=sOFF)
- {
- state=sBLINK;
- color=cBLINK;
- return true;
- }
- }
- bool Semafor::turnOUT()
- {
- if (state=sON)
- {
- state=sOUT;
- color=
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement