Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <tchar.h>
  4. #include <iostream>
  5. #include <cstdlib>
  6. #include <string>
  7. #include <stdlib.h>
  8.  
  9. using namespace std;
  10.  
  11. typedef char imie[20];
  12.  
  13. class Zwierze {
  14. public:
  15.     int wielkosc;
  16.     double sila;
  17.     imie Imie;
  18.     int typ;
  19.     Zwierze(const Zwierze &animal) {
  20.         strcpy(Imie, animal.Imie);
  21.         wielkosc = animal.wielkosc;
  22.         sila = animal.sila;
  23.         typ = animal.typ;
  24.     }
  25.     Zwierze(imie name, int wzrost, double fors, int rodzaj)
  26.     {
  27.         strcpy(this->Imie, name);
  28.         this->wielkosc = wzrost;
  29.         this->sila = fors;
  30.         this->typ = rodzaj;
  31.     }
  32. };
  33.  
  34. //class Rosliny : public Zwierze {
  35. //string typ = "trawa";
  36. //};
  37.  
  38. class Sawanna {
  39. public:
  40.     Zwierze* Zwierzeta;
  41.     void Spotkanie(Zwierze A, Zwierze B);
  42. };
  43.  
  44. void Zjedzone(Zwierze A, Zwierze B)
  45. {
  46.     if (A.sila < B.sila)
  47.         throw A;
  48.     cout << "Zwierze " << B.Imie << " zjadlo zwierze " << A.Imie << endl;
  49. }
  50.  
  51. void Sawanna::Spotkanie(Zwierze A, Zwierze B)
  52. {
  53.     try
  54.     {
  55.         Zjedzone(A, B);
  56.     }
  57.     catch (const Zwierze& C)
  58.     {
  59.         cout << "Zwierze " << C.Imie << "nie moglo zostac zjedzone" << endl;
  60.     }
  61. }
  62.  
  63.  
  64.  
  65. int main()
  66. {
  67.     Zwierze *Alabama = new Zwierze("Zenek", 15, 20, 1);
  68.     Zwierze *Birsbene = new Zwierze("Konstanty", 10, 10, 0);
  69.  
  70.     Sawanna KrolLew;
  71.     Zwierze** ferajna = new Zwierze*[10];
  72.     ferajna[0] = Alabama;
  73.     ferajna[1] = Birsbene;
  74.  
  75.     KrolLew.Spotkanie(*Alabama, *Birsbene);
  76.     cout << endl;
  77.     cout << endl;
  78.     cout << endl;
  79.     cout << endl;
  80.     cout << endl;
  81.     cout << endl;
  82.     cout << endl;
  83.     cout << endl;
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement