Guest User

menu.cpp

a guest
Oct 24th, 2016
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. #include "Menu.hpp"
  2.  
  3. using namespace std;
  4.  
  5. void gotoxy( const int x, const int y )
  6. {
  7.     COORD coord = { x, y };
  8.     SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord );
  9. }
  10.  
  11. int OpcjaA()
  12. {
  13.     return 0;
  14. }
  15.  
  16. int OpcjaB()
  17. {
  18.     return 0;
  19. }
  20.  
  21. int main()
  22. {
  23.     int wybor;
  24.     int poprzedniWybor;
  25.     bool wykonujPetle;
  26.  
  27.     while( 1 )
  28.     {
  29.         wybor = 0;
  30.         poprzedniWybor = wybor;
  31.         wykonujPetle = true;
  32.  
  33.         system( "cls" );
  34.         gotoxy( 3, 1 );
  35.         cout << "Opcja A";
  36.         gotoxy( 3, 3 );
  37.         cout << "Opcja B";
  38.         gotoxy( 3, 5 );
  39.         cout << "Exit";
  40.  
  41.         while( wykonujPetle )
  42.         {
  43.             gotoxy( 1, wybor * 2 + 1 );
  44.             cout << static_cast < char >( 16 );
  45.  
  46.             poprzedniWybor = wybor;
  47.             switch( getch() )
  48.             {
  49.             case 224:
  50.                 switch( getch() )
  51.                 {
  52.                 case 72:
  53.                     if( 0 < wybor ) wybor--;
  54.                     else wybor = 2;
  55.  
  56.                     break;
  57.  
  58.                 case 80:
  59.                     if( wybor < 2 ) wybor++;
  60.                     else wybor = 0;
  61.  
  62.                     break;
  63.  
  64.                 case 77:
  65.                     switch( wybor )
  66.                     {
  67.                     case 0:
  68.                         OpcjaA();
  69.                         break;
  70.  
  71.                     case 1:
  72.                         OpcjaB();
  73.                         break;
  74.  
  75.                     case 2:
  76.                         return 0;
  77.                     }
  78.                 }
  79.                 break;
  80.             }
  81.  
  82.             gotoxy( 1, poprzedniWybor * 2 + 1 );
  83.             cout << " ";
  84.         }
  85.     }
  86.     return 0;
  87. }
Add Comment
Please, Sign In to add comment