Advertisement
Gregb12

Untitled

Apr 6th, 2017
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.89 KB | None | 0 0
  1. #include <iostream>
  2. #include "bufory.h"
  3.  
  4. using namespace std;
  5. int testkolejka()
  6. {
  7.     int wybor;
  8.     double wartosc;
  9.     kolejka kol;
  10.     cout << "MENU GLOWNE KOLEJKI:"<<endl;
  11.     cout << "------------------------------------------"<<endl;
  12.     cout << "1. WSTAW (za pomoca wstaw) "<<endl;
  13.     cout << "2. WSTAW (za pomoca +=) "<<endl;
  14.     cout << "3. POBIERZ (za pomoca usun) "<<endl;
  15.     cout << "4. POBIERZ (za pomoca --) "<<endl;
  16.     cout << "5. SPRAWDZ (za pomoca gotowy) "<<endl;
  17.     cout << "7. SPRAWDZ (za pomoca *) "<<endl;
  18.     cout << "8. ILE (ile elementow w kolejce) "<<endl;
  19.     cout << "9. Koniec programu "<<endl;
  20.     cout << "------------------------------------------"<<endl;
  21.  
  22.  
  23.     do
  24.     {
  25.         cout << "Wybor: ";
  26.         cin >> wybor;
  27.  
  28.         switch (wybor)
  29.         {
  30.         case 1:
  31.             cout<<"wartosc: "<<endl;
  32.             cin>>wartosc;
  33.             try { kol.wstaw(wartosc); } catch (string s) { cout << s << endl; }
  34.             break;
  35.         case 2:
  36.             cout<<"wartosc: "<<endl;
  37.             cin>>wartosc;
  38.             try { kol+=wartosc; } catch (string s) { cout << s << endl; }
  39.             break;
  40.         case 3:
  41.             try { kol.usun(); } catch (string s) { cout << s << endl; }
  42.             break;
  43.         case 4:
  44.             try { --kol; } catch (string s) { cout << s << endl; }
  45.             break;
  46.         case 5:
  47.             try { cout<<kol.gotowy()<<endl; } catch (string s) { cout << s << endl; }
  48.             break;
  49.         case 6:
  50.             try { cout<<*kol<<endl; } catch (string s) { cout << s << endl; }
  51.             break;
  52.         case 7:
  53.             try { cout<<kol.ile()<<endl; } catch (string s) { cout << s << endl; }
  54.             break;
  55.         }
  56.  
  57.     }
  58.     while (wybor != 8);
  59.     return 0;
  60. }
  61.  
  62. int teststos()
  63. {
  64.     int wybor;
  65.     double wartosc;
  66.     stos sts;
  67.     cout << "MENU GLOWNE LISTY:"<<endl;
  68.     cout << "------------------------------------------"<<endl;
  69.     cout << "1. WSTAW (za pomoca wstaw) "<<endl;
  70.     cout << "2. WSTAW (za pomoca +=) "<<endl;
  71.     cout << "3. POBIERZ (za pomoca usun) "<<endl;
  72.     cout << "4. POBIERZ (za pomoca --) "<<endl;
  73.     cout << "5. SPRAWDZ (za pomoca gotowy) "<<endl;
  74.     cout << "6. SPRAWDZ (za pomoca *) "<<endl;
  75.     cout << "7. ILE (ile elementow na stosie) "<<endl;
  76.     cout << "8. Koniec programu "<<endl;
  77.     cout << "------------------------------------------"<<endl;
  78.  
  79.  
  80.     do
  81.     {
  82.         cout << "Wybor: ";
  83.         cin >> wybor;
  84.  
  85.         switch (wybor)
  86.         {
  87.         case 1:
  88.             cout<<"wartosc: "<<endl;
  89.             cin>>wartosc;
  90.             try { sts.wstaw(wartosc); } catch (string s) { cout << s << endl; }
  91.             break;
  92.         case 2:
  93.             cout<<"wartosc: "<<endl;
  94.             cin>>wartosc;
  95.             try { sts+=wartosc; } catch (string s) { cout << s << endl; }
  96.             break;
  97.         case 3:
  98.             try { sts.usun(); } catch (string s) { cout << s << endl; }
  99.             break;
  100.         case 4:
  101.             try { --sts; } catch (string s) { cout << s << endl; }
  102.             break;
  103.         case 5:
  104.             try { cout<<sts.gotowy()<<endl; } catch (string s) { cout << s << endl; }
  105.             break;
  106.         case 6:
  107.             try { cout<<*sts<<endl; } catch (string s) { cout << s << endl; }
  108.             break;
  109.         case 7:
  110.             try { cout<<sts.ile()<<endl; } catch (string s) { cout << s << endl; }
  111.             break;
  112.         }
  113.  
  114.     }
  115.     while (wybor != 8);
  116.     return 0;
  117. }
  118.  
  119.  
  120. int main()
  121. {
  122.     int wybor;
  123.     cout << "MENU GLOWNE TESTU:"<<endl;
  124.     cout << "------------------------------------------"<<endl;
  125.     cout << "1. TEST KOLEJKI"<<endl;
  126.     cout << "2. TEST STOSU "<<endl;
  127.     cout << "3. TEST LISTY "<<endl;
  128.     cout << "4. KONIEC PSOT "<<endl;
  129.     cout << "------------------------------------------"<<endl;
  130.  
  131.  
  132.     do
  133.     {
  134.         cout << "Wybor: ";
  135.         cin >> wybor;
  136.  
  137.         switch (wybor)
  138.         {
  139.         case 1:
  140.             testkolejka();
  141.             cout << "MENU GLOWNE TESTU:"<<endl;
  142.             cout << "------------------------------------------"<<endl;
  143.             cout << "1. TEST KOLEJKI"<<endl;
  144.             cout << "2. TEST STOSU "<<endl;
  145.             cout << "3. TEST LISTY "<<endl;
  146.             cout << "4. KONIEC PSOT "<<endl;
  147.             cout << "------------------------------------------"<<endl;
  148.             break;
  149.         case 2:
  150.             teststos();
  151.             cout << "MENU GLOWNE TESTU:"<<endl;
  152.             cout << "------------------------------------------"<<endl;
  153.             cout << "1. TEST KOLEJKI"<<endl;
  154.             cout << "2. TEST STOSU "<<endl;
  155.             cout << "3. TEST LISTY "<<endl;
  156.             cout << "4. KONIEC PSOT "<<endl;
  157.             cout << "------------------------------------------"<<endl;
  158.             break;
  159.         case 3:
  160.             break;
  161.         }
  162.  
  163.     }
  164.     while (wybor != 4);
  165.     return 0;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement