Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- class Sportowiec {
- protected:
- std::string imie;
- std::string nazwisko;
- int wiek;
- std::string kraj;
- std::string dyscyplina;
- public:
- Sportowiec(std::string imie, std::string nazwisko,int wiek,std::string kraj, std::string dyscyplina) {
- this->imie = imie;
- this->nazwisko = nazwisko;
- this->wiek = wiek;
- this->kraj = kraj;
- this->dyscyplina = dyscyplina;
- };
- virtual void setDodatkoweInfromacja(std::string arg1, std::string arg2) = 0;
- bool isSetString(std::string arg1) {
- if (arg1.length() > 0) {
- return true;
- }
- else return false;
- }
- virtual std::string drukujWizytowke() {
- std::cout << "Imie: " << imie << std::endl;
- std::cout << "Nazwisko: " << nazwisko << std::endl;
- std::cout << "Wiek: " << wiek << std::endl;
- std::cout << "Kraj: " << kraj << std::endl;
- std::cout << "Dyscyplina: " << dyscyplina << std::endl;
- }
- friend std::ostream & operator << (std::ostream &out, Sportowiec &s);
- };
- class Pilkarz : public Sportowiec {
- private:
- std::string pozycja;
- std::string zespolLigowy;
- public:
- Pilkarz(std::string imie, std::string nazwisko, int wiek, std::string kraj, std::string dyscyplina) : Sportowiec(imie, nazwisko, wiek, kraj, "pilka nozna") {}
- void setDodatkoweInfromacja(std::string arg1, std::string arg2) {
- this->pozycja = arg1;
- this->zespolLigowy = arg2;
- }
- std::string drukujWizytowke() {
- Sportowiec::drukujWizytowke();
- if (isSetString(pozycja))
- {
- std::cout << "Pozycja: " << pozycja << std::endl;
- }
- if (isSetString(zespolLigowy))
- {
- std::cout << "Zespol ligowy: " << zespolLigowy << std::endl;
- }
- }
- };
- class Plywak : public Sportowiec {
- private:
- std::string styl;
- public:
- Plywak(const std::string imie, std::string nazwisko, int wiek, std::string kraj, std::string dyscyplina) : Sportowiec(imie, nazwisko, wiek, kraj, "plywanie") {}
- void setDodatkoweInformacje(std::string arg) {
- this->styl = arg;
- }
- std::string drukujWizytowke() {
- Sportowiec::drukujWizytowke();
- if (isSetString(styl))
- {
- std::cout << "Styl: " << styl << std::endl;
- }
- }
- };
- std::ostream & operator << (std::ostream &out, Sportowiec &s) {
- return out << s.drukujWizytowke();
- }
- using namespace std;
- int main()
- {
- Pilkarz nowy1("Seba" ,"Nowak", 18, "polska");
- nowy1.setDodatkoweInfromacja("napastnik", "");
- Plywak nowy2("Damian", "Kowall");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement