Advertisement
Guest User

Szlif

a guest
May 13th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. #include <windows.h>
  4. #include <string.h>
  5. #include <vector>
  6. #include <conio.h>
  7. #include <cstdlib>
  8.  
  9. using namespace std;
  10.  
  11. class Urzadzenie
  12. {
  13. protected:
  14.     string firma;
  15.     int obroty;
  16.  
  17. public:
  18.     Urzadzenie() {}
  19.     Urzadzenie(string firma, int obroty)
  20.     {
  21.         this->firma = firma;
  22.         this->obroty = obroty;
  23.     }
  24.  
  25.     string daj_firme() { return firma; }
  26.     int daj_obroty() { return obroty; }
  27.     void pokaz_opis() { cout << "Firma " << firma << " obroty " << obroty << endl; }
  28. };
  29.  
  30. class SzlifierkaKatowa : public Urzadzenie
  31. {
  32. private:
  33.     int moc, tarcza;
  34.  
  35. public:
  36.     SzlifierkaKatowa() {}
  37.     SzlifierkaKatowa(string firma, int moc, int tarcza, int obroty) : Urzadzenie (firma,obroty)
  38.     {
  39. //      this->moc = moc;
  40. //      this->tarcza = tarcza;
  41.     }
  42.  
  43.     int daj_moc() { return moc; }
  44.     int daj_tarcze() { return tarcza; }
  45.     void pokaz_opis()
  46.     {
  47.         cout << "Firma szlifierki : " << firma << endl;
  48.         cout << "Moc szlifierki : " << moc << endl;
  49.         cout << "Srednica tarczy : " << tarcza << endl;
  50.         cout << "Obroty : " << obroty << endl;
  51.     }
  52. };
  53.  
  54.  
  55. class WiertarkoWkretarka : public Urzadzenie
  56. {
  57. private:
  58.     double napiecie;
  59.     string bateria;
  60.     int czas_ladow;
  61.  
  62. public:
  63.     WiertarkoWkretarka() {}
  64.     WiertarkoWkretarka(string firma, double napiecie, string bateria, int czas_ladow, int obroty) : Urzadzenie(firma,obroty)
  65.     {
  66.         this->firma = firma;
  67.         this->napiecie = napiecie;
  68.         this->bateria = bateria;
  69.         this->czas_ladow = czas_ladow;
  70.     }
  71.  
  72.     double daj_napiecie() { return napiecie; }
  73.     string daj_baterie() { return bateria; }
  74.     int daj_czas_ladow() { return czas_ladow; }
  75.     void pokaz_opis()
  76.     {
  77.         cout << "Firma wiertarki :  " << firma << endl;
  78.         cout << "Napiecie wiertarki : " << napiecie << endl;
  79.         cout << "Bateria : " << bateria << endl;
  80.         cout << "Czas ladowania : " << czas_ladow << endl;
  81.         cout << "Obroty : " << obroty << endl;
  82.  
  83.         cout << endl;
  84.     }
  85.     void pokaz_opis(string firma, double napiecie, string bateria, int czas_ladow, int obroty)
  86.     {
  87.         cout << "Firma wiertarki :  " << firma << endl;
  88.         cout << "Napiecie wiertarki : " << napiecie << endl;
  89.         cout << "Bateria : " << bateria << endl;
  90.         cout << "Czas ladowania : " << czas_ladow << endl;
  91.         cout << "Obroty : " << obroty << endl;
  92.  
  93.         cout << endl;
  94.     }
  95. };
  96.  
  97.  
  98.  
  99. int main()
  100. {
  101.     int wybor,obroty = 0;
  102.  
  103.  
  104.     WiertarkoWkretarka wiertarka[] = {
  105.             WiertarkoWkretarka("Sztil", 8, "jonowa", 120, 3000),
  106.             WiertarkoWkretarka("Blackdeker", 25, "litowa", 180, 4000),
  107.             WiertarkoWkretarka("husqvarna", 18, "jonowa", 120, 2500),
  108.             WiertarkoWkretarka("Bosz", 15, "litowo-jonowa", 60, 1000),
  109.     };
  110.  
  111.     SzlifierkaKatowa szlifierka[] = {
  112.             SzlifierkaKatowa("Sztil", 400, 300, 3000),
  113.             SzlifierkaKatowa("Blackdeker", 600, 200, 4000),
  114.             SzlifierkaKatowa("husqvarna", 350, 150, 2500),
  115.             SzlifierkaKatowa("Bosz", 800, 230, 1000),
  116.     };
  117.  
  118.     menu:
  119.  
  120.     cout << "|====================MENU====================|" << endl;
  121.     cout << "1.Wyswietl tablice wiertarek " << endl;
  122.     cout << "2.Wyswietl tablice szlifierek " << endl;
  123.     cout << "3.Wypisz wiertarke z najszybciej ladujaca sie bateria oraz szlifierka z najwieksza il. obrotow " << endl;
  124.  
  125.     cout << "Wybierz jedna z opcji : " << endl;
  126.     cin >> wybor;
  127.  
  128.     switch (wybor)
  129.     {
  130.         case 1:
  131.         {
  132.             system("cls");
  133.             cout << "Wybrales wiertarki !" << endl;
  134.  
  135.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  136.             wiertarka[1].pokaz_opis("Sztil", 8, "jonowa", 120, 5000);
  137.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  138.             wiertarka[2].pokaz_opis("Blackdeker", 25, "litowa", 180, 2000);
  139.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  140.             wiertarka[3].pokaz_opis("husqvarna", 18, "jonowa", 120, 1500);
  141.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  142.             wiertarka[4].pokaz_opis("Bosz", 15, "litowo-jonowa", 60, 2800);
  143.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  144.  
  145.             char powrot;
  146.             do
  147.             {
  148.                 cout << "Kliknij 't' aby powrocic do menu ";
  149.                 cin >> powrot;
  150.                 system("cls");
  151.                 goto menu;
  152.             } while (powrot);
  153.  
  154.             break;
  155.         }
  156.         case 2:
  157.         {
  158.             system("cls");
  159.             cout << "Wybrales szlifierki !" << endl;
  160.  
  161.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  162.             szlifierka[1].pokaz_opis("Sztil", 400, 300, 3000);
  163.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  164.             szlifierka[2].pokaz_opis("Blackdeker", 600, 200, 4000);
  165.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  166.             szlifierka[3].pokaz_opis("husqvarna", 350, 150, 2500);
  167.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  168.             szlifierka[4].pokaz_opis("Bosz", 800, 230, 1000);
  169.             cout << endl; cout << "|=============================================================|" << endl; cout << endl;
  170.  
  171.             char powrot;
  172.             do
  173.             {
  174.                 cout << "Kliknij 't' aby powrocic do menu ";
  175.                 cin >> powrot;
  176.                 system("cls");
  177.                 goto menu;
  178.             } while (powrot);
  179.  
  180.             break;
  181.         }
  182.         case 3:
  183.         {
  184.             system("cls");
  185.             cout << "Wybrales wyszukiwanie wiertarki i szlifierki " << endl;
  186.  
  187.             cout << "|===========================================================|" << endl;
  188.  
  189.             int min = 0, max = 0;// pierwszy element
  190.  
  191.             for(int i = 1; i < 4; i++)
  192.             {
  193.                 if(szlifierka[i].daj_obroty() > szlifierka[max].daj_obroty())
  194.                 {
  195.                     max = i;
  196.                 }
  197.             }
  198.  
  199.             szlifierka[max].pokaz_opis();
  200.  
  201.             cout << "|===========================================================|" << endl;
  202.  
  203.             for(int j = 1; j < 4; j++)
  204.             {
  205.                 if(wiertarka[j].daj_czas_ladow() < wiertarka[min].daj_czas_ladow())
  206.                 {
  207.                     min = j;
  208.                 }
  209.             }
  210.  
  211.             wiertarka[min].pokaz_opis();
  212.  
  213.             cout << "|===========================================================|" << endl;
  214.  
  215.  
  216.             char powrot;
  217.             do
  218.             {
  219.                 cout << "Kliknij 't' aby powrocic do menu ";
  220.                 cin >> powrot;
  221.                 system("cls");
  222.                 goto menu;
  223.             } while (powrot);
  224.  
  225.             break;
  226.         }
  227.  
  228.         default:
  229.         {
  230.             cout << "Wybierz prawidlowa opcje 1-3 ! " << endl;
  231.             char powrot;
  232.             do
  233.             {
  234.                 cout << "Kliknij 't' aby powrocic do menu ";
  235.                 cin >> powrot;
  236.                 system("cls");
  237.                 goto menu;
  238.             } while (powrot);
  239.             break;
  240.         }
  241.  
  242.  
  243.     }
  244.  
  245.  
  246.  
  247.  
  248.     return 0;
  249. }
  250.  
  251.  
  252.  
  253. // wolsza łukasz dziedziczenie lab 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement