Advertisement
DescendingBear

Dziedziczenie 1

Nov 10th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4.  
  5. class PLN{
  6.       public:
  7.             PLN(int w_n, int h_n, int d_n){};
  8.             PLN(){};
  9.  
  10.             virtual float oblicz_powierzchnie() = 0;
  11.  
  12.             float za_duza_powierzchnia(float ograniczenie)
  13.             {
  14.                 if (oblicz_powierzchnie() > ograniczenie)
  15.                 {
  16.                     cout<<"Za duze pole powierzchni!"<<endl;
  17.                     return true;
  18.                 }
  19.                 else
  20.                 {
  21.                     cout<<"Akceptowalne pole powierzchni!"<<endl;
  22.                     return false;
  23.                 }
  24.             }
  25.             int w, h, d;
  26. };
  27.  
  28. class Moneta: public PLN{
  29. public:
  30.     Moneta(int w1, int h1, int d1): PLN(w1, h1, d1) {};
  31.  
  32.     float oblicz_powierzchnie()
  33.     {
  34.         float circ = d*d*3.14;
  35.         return circ;
  36.     }
  37. };
  38.  
  39. class Banknot: public PLN{
  40. public:
  41.     Banknot(int w1, int h1, int d1): PLN(w1, h1, d1) {};
  42.  
  43.         float oblicz_powierzchnie()
  44.     {
  45.         float rect = w*h;
  46.         return rect;
  47.     }
  48. };
  49. int main()
  50. {
  51.     Banknot kilometr (1.44, 1.72, 0);
  52.     kilometr.oblicz_powierzchnie();
  53.    
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement