Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- class Sportowiec
- {
- private:
- string imieinazwisko, plec, dyscyplina;
- int wiek;
- bool medale;
- public:
- void disp()
- {
- string med;
- if (medale == true) med = "Tak";
- else med = "Nie";
- cout << setw(20) << left << "Imie i nazwisko" << setw(10) << left << "Plec" << setw(6) << left << "Wiek" << setw(10) << left << "Medale" << setw(15) << left << "Dyscyplina" << endl;
- cout << setw(20) << left << imieinazwisko << setw(10) << left << plec << setw(6) << left << wiek << setw(10) << left << med << setw(15) << left << dyscyplina << endl;
- }
- Sportowiec()
- {
- imieinazwisko = "Jan Nowak";
- plec = "Mezczyzna";
- wiek = 22;
- medale = 0;
- dyscyplina = "Tyczkarz";
- cout << "Konstruktor domyslny klasy sportowiec zostal wywolany" << endl;
- }
- Sportowiec(string i, string p, int w, bool m, string d)
- {
- imieinazwisko = i;
- plec = p;
- wiek = w;
- medale = m;
- dyscyplina = d;
- cout << "Konstruktor parametryczny klasy sportowiec zostal wywolany" << endl;
- }
- void Nagroda()
- {
- if(medale==false) medale = true;
- }
- };
- class Sprinter:public Sportowiec
- {
- private:
- float rek60, wyn60, rek100, wyn100;
- public:
- void wyswietl()
- {
- Sportowiec::disp();
- cout << endl;
- cout << setw(15) << left << "Rekord na 60m" << setw(15) << left << "Ostatni na 60m" << setw(15) << left << "Rekord na 100m" << setw(15) << left << "Ostatni na 100m" << endl;
- cout << setw(15) << left << rek60 << setw(15) << left << wyn60 << setw(15) << left << rek100 << setw(15) << left << wyn100 << endl;
- }
- Sprinter():Sportowiec()
- {
- rek60 = 0;
- wyn60 = 0;
- rek100 = 0;
- wyn100 = 0;
- cout << "Konstruktor domyslny klasy sprinter zostal wywolany" << endl;
- }
- Sprinter(float r60, float w60, float r100, float w100, string i, string p, int w, bool m, string d):Sportowiec(i,p,w,m,d)
- {
- rek60 = r60;
- wyn60 = w60;
- rek100 = r100;
- wyn100 = w100;
- cout << "Konstruktor parametryczny klasy sprinter zostal wywolany" << endl;
- }
- void Nowy()
- {
- float dyst, czas;
- cout << "Podaj dystant biegu (wpisz ""60"" lub ""100""):";
- cin >> dyst;
- cout << "Podaj czas biegu:";
- cin >> czas;
- if(dyst==60)
- {
- wyn60 = czas;
- if(czas<rek60) rek60 = czas;
- }
- else if(dyst==100)
- {
- wyn100 = czas;
- if(czas<rek100) rek100 = czas;
- }
- else cout << "Podano niepoprawny dystans!" << endl;
- }
- };
- int main(int argc, char** argv)
- {
- Sportowiec s1;
- s1.disp();
- s1.Nagroda();
- s1.disp();
- cout << endl;
- Sprinter sp1(10,11,13,14,"Kazimierz Wielki","Mezczyzna",30,true,"Sprinter");
- sp1.wyswietl();
- sp1.Nowy();
- sp1.wyswietl();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement