Guest User

Untitled

a guest
Dec 12th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. class Interface{
  2. public:
  3.     Interface(){};
  4.     virtual States Action(States s, uint8_t key) = 0;
  5.     virtual uint8_t ReadKey() = 0;
  6. };
  7.  
  8. class ob : public Interface{
  9. public:
  10.     ob(){
  11.         Text.ClrScr();
  12.         Text.GoTo(0,0);
  13.         Text.Write("constructor ob \n");
  14.     };
  15.    
  16.     virtual States Action(States s, uint8_t key){
  17.         Text.ClrScr();
  18.         Text.GoTo(0,0);
  19.         Text.Write("ob override Action\n");
  20.         return sInputWindow;
  21.     };
  22.    
  23.     virtual uint8_t ReadKey(void){
  24.         return 'b';
  25.     };
  26.    
  27. };
  28.  
  29. class oa : public Interface {
  30. public:
  31.     oa(){
  32.         Text.ClrScr();
  33.         Text.GoTo(0,0);
  34.         Text.Write("constructor oa \n");
  35.     };
  36.    
  37.     virtual States Action(States s, uint8_t key){
  38.         Text.ClrScr();
  39.         Text.GoTo(0,0);
  40.         Text.Write("oa override Action\n");
  41.         return sMainWindow;
  42.     };
  43.    
  44.     virtual uint8_t ReadKey(void){
  45.         return 'a';
  46.     }; 
  47. };
  48. int main(void)
  49. {
  50.     oa a;
  51.     ob b;
  52.    
  53.     States s = sMainWindow;
  54.    
  55.     Interface* obj;
  56.    
  57.     obj  = &a;
  58.    
  59.     while(1){
  60.         s = obj->Action(s, obj->ReadKey());
  61.         if( s == sMainWindow){
  62.             obj = &b;
  63.         }else{
  64.             obj = &a;
  65.         }
  66.         delay(0x2fffff);
  67.     };
  68.        
  69.        
  70. };
Advertisement
Add Comment
Please, Sign In to add comment