Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Zwierze
- {
- public:
- //atrybuty
- string gatunek;
- string imie;
- int wiek;
- //metody
- void dodaj_zwierze()
- {
- cout << "Dodawanie nowego zwierzecia do bazy: "<<endl;
- cout << "Podaj gatunek: ";
- cin >> gatunek;
- cout << "Podaj imie: ";
- cin >> imie;
- cout << "Podaj wiek: ";
- cin >> wiek;
- }
- void daj_glos()
- {
- if (gatunek == "kot") cout<<imie<<" lat"<<wiek<< ": Miau!";
- else if (gatunek == "koza") cout<<imie<< " lat"<<wiek<<": Beee!";
- else if (gatunek == "krowa") cout<<imie<<" lat"<<wiek<<": Muuu!";
- else cout << "Nieznany gatunek!";
- }
- };
- int main()
- {
- Zwierze z1;
- z1.dodaj_zwierze();
- z1.daj_glos();
- Zwierze z2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement