Advertisement
Guest User

semaformoci

a guest
Oct 23rd, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.48 KB | None | 0 0
  1. #ifndef SEMAFOR_HPP_INCLUDED
  2. #define SEMAFOR_HPP_INCLUDED
  3.  
  4. enum States { sOFF, sON, sBLINK, sOUT};
  5. enum Colors { cNONE, cBLINK, cRED, cYELLOWRED, cYELLOW, cGREEN}
  6.  
  7.  
  8. class Semafor
  9. {
  10.     private:
  11.             States state;
  12.             Colors color;
  13.     public:
  14.             Semafor () { state=sOFF; color=sNONE}
  15.             enum getSTATE () { return state }
  16.             enum getCOLOR () { return color }
  17.             bool turnON ();
  18.             bool turnOFF ();
  19.             bool turnBLINK ();
  20.             bool turnOUT ();
  21.             bool repair ();
  22.             bool changeCOLOR ();
  23. }
  24.  
  25. #endif // SEMAFOR_HPP_INCLUDED
  26.  
  27.  
  28. #include <iostream>
  29. #include "semafor.hpp"
  30.  
  31. usnig namespace std;
  32.  
  33.  
  34. bool Semafor::turnON()
  35. {
  36.     if (state=sOFF)
  37.         {
  38.             state=sON;
  39.             color=cRED;
  40.             return true;
  41.         }
  42.     else   return false;
  43. }
  44.  
  45. bool Semafor::turnOFF()
  46. {
  47.     if (state=sON)
  48.         {
  49.             state=sOF;
  50.             color=cNONE;
  51.             return true;
  52.         }
  53.     else if (state=sBLINK)
  54.                 {
  55.                     state=sOFF;
  56.                     color=cBLINK;
  57.                     return true;
  58.                 }
  59.           else  return false;  
  60. }
  61.  
  62. bool Semafor::turnBLINK()
  63. {
  64.     if (state=sOFF)
  65.         {
  66.             state=sBLINK;
  67.             color=cBLINK;
  68.             return true;
  69.         }
  70. }
  71.  
  72. bool Semafor::turnOUT()
  73. {
  74.     if (state=sON)
  75.         {
  76.             state=sOUT;
  77.             color=
  78.         }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement