Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <tchar.h>
- #include <iostream>
- #include <cstdlib>
- #include <string>
- #include <stdlib.h>
- using namespace std;
- typedef char imie[20];
- class Zwierze {
- public:
- int wielkosc;
- double sila;
- imie Imie;
- int typ;
- Zwierze(const Zwierze &animal) {
- strcpy(Imie, animal.Imie);
- wielkosc = animal.wielkosc;
- sila = animal.sila;
- typ = animal.typ;
- }
- Zwierze(imie name, int wzrost, double fors, int rodzaj)
- {
- strcpy(this->Imie, name);
- this->wielkosc = wzrost;
- this->sila = fors;
- this->typ = rodzaj;
- }
- };
- //class Rosliny : public Zwierze {
- //string typ = "trawa";
- //};
- class Sawanna {
- public:
- Zwierze* Zwierzeta;
- void Spotkanie(Zwierze A, Zwierze B);
- };
- void Zjedzone(Zwierze A, Zwierze B)
- {
- if (A.sila < B.sila)
- throw A;
- cout << "Zwierze " << B.Imie << " zjadlo zwierze " << A.Imie << endl;
- }
- void Sawanna::Spotkanie(Zwierze A, Zwierze B)
- {
- try
- {
- Zjedzone(A, B);
- }
- catch (const Zwierze& C)
- {
- cout << "Zwierze " << C.Imie << "nie moglo zostac zjedzone" << endl;
- }
- }
- int main()
- {
- Zwierze *Alabama = new Zwierze("Zenek", 15, 20, 1);
- Zwierze *Birsbene = new Zwierze("Konstanty", 10, 10, 0);
- Sawanna KrolLew;
- Zwierze** ferajna = new Zwierze*[10];
- ferajna[0] = Alabama;
- ferajna[1] = Birsbene;
- KrolLew.Spotkanie(*Alabama, *Birsbene);
- cout << endl;
- cout << endl;
- cout << endl;
- cout << endl;
- cout << endl;
- cout << endl;
- cout << endl;
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement