Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <windows.h>
- #include <string.h>
- #include <vector>
- #include <conio.h>
- #include <cstdlib>
- using namespace std;
- class Urzadzenie
- {
- protected:
- string firma;
- int obroty;
- public:
- Urzadzenie() {}
- Urzadzenie(string firma, int obroty)
- {
- this->firma = firma;
- this->obroty = obroty;
- }
- string daj_firme() { return firma; }
- int daj_obroty() { return obroty; }
- void pokaz_opis() { cout << "Firma " << firma << " obroty " << obroty << endl; }
- };
- class SzlifierkaKatowa : public Urzadzenie
- {
- private:
- int moc, tarcza;
- public:
- SzlifierkaKatowa() {}
- SzlifierkaKatowa(string firma, int moc, int tarcza, int obroty) : Urzadzenie (firma,obroty)
- {
- // this->moc = moc;
- // this->tarcza = tarcza;
- }
- int daj_moc() { return moc; }
- int daj_tarcze() { return tarcza; }
- void pokaz_opis()
- {
- cout << "Firma szlifierki : " << firma << endl;
- cout << "Moc szlifierki : " << moc << endl;
- cout << "Srednica tarczy : " << tarcza << endl;
- cout << "Obroty : " << obroty << endl;
- }
- };
- class WiertarkoWkretarka : public Urzadzenie
- {
- private:
- double napiecie;
- string bateria;
- int czas_ladow;
- public:
- WiertarkoWkretarka() {}
- WiertarkoWkretarka(string firma, double napiecie, string bateria, int czas_ladow, int obroty) : Urzadzenie(firma,obroty)
- {
- this->firma = firma;
- this->napiecie = napiecie;
- this->bateria = bateria;
- this->czas_ladow = czas_ladow;
- }
- double daj_napiecie() { return napiecie; }
- string daj_baterie() { return bateria; }
- int daj_czas_ladow() { return czas_ladow; }
- void pokaz_opis()
- {
- cout << "Firma wiertarki : " << firma << endl;
- cout << "Napiecie wiertarki : " << napiecie << endl;
- cout << "Bateria : " << bateria << endl;
- cout << "Czas ladowania : " << czas_ladow << endl;
- cout << "Obroty : " << obroty << endl;
- cout << endl;
- }
- void pokaz_opis(string firma, double napiecie, string bateria, int czas_ladow, int obroty)
- {
- cout << "Firma wiertarki : " << firma << endl;
- cout << "Napiecie wiertarki : " << napiecie << endl;
- cout << "Bateria : " << bateria << endl;
- cout << "Czas ladowania : " << czas_ladow << endl;
- cout << "Obroty : " << obroty << endl;
- cout << endl;
- }
- };
- int main()
- {
- int wybor,obroty = 0;
- WiertarkoWkretarka wiertarka[] = {
- WiertarkoWkretarka("Sztil", 8, "jonowa", 120, 3000),
- WiertarkoWkretarka("Blackdeker", 25, "litowa", 180, 4000),
- WiertarkoWkretarka("husqvarna", 18, "jonowa", 120, 2500),
- WiertarkoWkretarka("Bosz", 15, "litowo-jonowa", 60, 1000),
- };
- SzlifierkaKatowa szlifierka[] = {
- SzlifierkaKatowa("Sztil", 400, 300, 3000),
- SzlifierkaKatowa("Blackdeker", 600, 200, 4000),
- SzlifierkaKatowa("husqvarna", 350, 150, 2500),
- SzlifierkaKatowa("Bosz", 800, 230, 1000),
- };
- menu:
- cout << "|====================MENU====================|" << endl;
- cout << "1.Wyswietl tablice wiertarek " << endl;
- cout << "2.Wyswietl tablice szlifierek " << endl;
- cout << "3.Wypisz wiertarke z najszybciej ladujaca sie bateria oraz szlifierka z najwieksza il. obrotow " << endl;
- cout << "Wybierz jedna z opcji : " << endl;
- cin >> wybor;
- switch (wybor)
- {
- case 1:
- {
- system("cls");
- cout << "Wybrales wiertarki !" << endl;
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- wiertarka[1].pokaz_opis("Sztil", 8, "jonowa", 120, 5000);
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- wiertarka[2].pokaz_opis("Blackdeker", 25, "litowa", 180, 2000);
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- wiertarka[3].pokaz_opis("husqvarna", 18, "jonowa", 120, 1500);
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- wiertarka[4].pokaz_opis("Bosz", 15, "litowo-jonowa", 60, 2800);
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- char powrot;
- do
- {
- cout << "Kliknij 't' aby powrocic do menu ";
- cin >> powrot;
- system("cls");
- goto menu;
- } while (powrot);
- break;
- }
- case 2:
- {
- system("cls");
- cout << "Wybrales szlifierki !" << endl;
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- szlifierka[1].pokaz_opis("Sztil", 400, 300, 3000);
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- szlifierka[2].pokaz_opis("Blackdeker", 600, 200, 4000);
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- szlifierka[3].pokaz_opis("husqvarna", 350, 150, 2500);
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- szlifierka[4].pokaz_opis("Bosz", 800, 230, 1000);
- cout << endl; cout << "|=============================================================|" << endl; cout << endl;
- char powrot;
- do
- {
- cout << "Kliknij 't' aby powrocic do menu ";
- cin >> powrot;
- system("cls");
- goto menu;
- } while (powrot);
- break;
- }
- case 3:
- {
- system("cls");
- cout << "Wybrales wyszukiwanie wiertarki i szlifierki " << endl;
- cout << "|===========================================================|" << endl;
- int min = 0, max = 0;// pierwszy element
- for(int i = 1; i < 4; i++)
- {
- if(szlifierka[i].daj_obroty() > szlifierka[max].daj_obroty())
- {
- max = i;
- }
- }
- szlifierka[max].pokaz_opis();
- cout << "|===========================================================|" << endl;
- for(int j = 1; j < 4; j++)
- {
- if(wiertarka[j].daj_czas_ladow() < wiertarka[min].daj_czas_ladow())
- {
- min = j;
- }
- }
- wiertarka[min].pokaz_opis();
- cout << "|===========================================================|" << endl;
- char powrot;
- do
- {
- cout << "Kliknij 't' aby powrocic do menu ";
- cin >> powrot;
- system("cls");
- goto menu;
- } while (powrot);
- break;
- }
- default:
- {
- cout << "Wybierz prawidlowa opcje 1-3 ! " << endl;
- char powrot;
- do
- {
- cout << "Kliknij 't' aby powrocic do menu ";
- cin >> powrot;
- system("cls");
- goto menu;
- } while (powrot);
- break;
- }
- }
- return 0;
- }
- // wolsza łukasz dziedziczenie lab 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement