Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <iterator>
- using namespace std;
- namespace folwark
- {
- class Zwierze
- {
- static int licznik;
- public:
- static int getLicznik();
- void dekrementuj_iterator(){licznik--;};
- private:
- string nazwa;
- int masa;
- public:
- Zwierze()
- {
- cout<<"Zostalo stworzone zwierze domyslnie bedzie to pies o masie rownej 10"<<endl;
- nazwa="Pies";
- masa=10;
- licznik++;
- }
- bool czy_ciezsze(int masa )
- {
- return (this->masa>masa) ? true:false;
- }
- ~Zwierze();
- string getNazwa() ;
- void setNazwa( string nazwa);
- int getMasa() ;
- void setMasa(int masa);
- //jest
- };
- }
- int folwark::Zwierze::licznik=0;
- folwark::Zwierze::~Zwierze()
- {
- cout<<nazwa<<" o masie "<<masa<<" zostaje aktualnie usuniete "<<endl;
- licznik--;
- cout<<"Zostalo "<<licznik<<" zwierzat "<<endl;
- }
- string folwark::Zwierze::getNazwa() {
- return nazwa;
- }
- void folwark::Zwierze::setNazwa( string nazwa) {
- Zwierze::nazwa = nazwa;
- }
- int folwark::Zwierze::getMasa() {
- return masa;
- }
- void folwark::Zwierze::setMasa(int masa) {
- Zwierze::masa = masa;
- }
- int folwark::Zwierze::getLicznik() {
- return licznik;
- }
- string dluzsza_nazwa(folwark::Zwierze *a,folwark::Zwierze *b)
- {
- return (a->getNazwa().length()>b->getNazwa().length()) ? a->getNazwa():(a->getNazwa().length()==b->getNazwa().length())? "OBA MAJA TA SAMA DLUGOSC! " +a->getNazwa() +" "+ b->getNazwa() :b->getNazwa();
- }
- int main() {
- folwark::Zwierze samotnik;
- samotnik.setMasa(500);
- samotnik.setNazwa("Slon");
- vector<folwark::Zwierze>tablca(2);
- vector<int*> wskazniki(100);
- tablca[0].setNazwa("kot");
- tablca[0].setMasa(5);
- cout<<"Liczba zwierzat aktualnie "<<tablca[0].getLicznik()<<endl;
- if(samotnik.czy_ciezsze(400))
- {
- cout<<samotnik.getNazwa()<<" jest ciezszy niz 400 "<<endl;
- } else cout<<samotnik.getNazwa()<<" jest lzejszy niz 400 "<<endl;
- string ktore_dluzsze_w_tablicy=dluzsza_nazwa(&samotnik,&tablca[1]);
- cout<<"W tablicy najdluzszym slowem jest "<<ktore_dluzsze_w_tablicy<<endl;
- auto test= tablca.begin();
- folwark::Zwierze *wskaznik=&*test;
- tablca.clear();
- cout<<"Aktualna ilosc zwierzat "<<samotnik.getLicznik()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement