Advertisement
Alx09

Untitled

Oct 28th, 2020
1,049
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. class Figura
  6. {
  7. protected:
  8.     string descriere;
  9. public:
  10.     virtual void deseneaza() = 0;
  11.    
  12. };
  13.  
  14. class Linie : public Figura
  15. {
  16. protected:
  17.     int x1, x2;
  18. public:
  19.     void deseneaza() {
  20.         descriere = "Linie orziontala";
  21.         int i;
  22.         for (i = 1; i < x1; i++)cout << " ";
  23.         for (i = x1; i <= x2; i++)
  24.             cout << "*";
  25.         cout << "\n";
  26.  
  27.     }
  28.     Linie(int x1, int x2) {
  29.         this->x1 = x1;
  30.         this->x2 = x2;
  31.     }
  32. };
  33. class Dreptunghi: public Linie
  34. {
  35. private:
  36.     int y;
  37. public:
  38.     void deseneaza() {
  39.         descriere = "un dreptunghi";
  40.         cout << "Aceasta este " << descriere.c_str() << "\n";
  41.         int i = 0;
  42.        
  43.         while (i < y) {
  44.             Linie::deseneaza();
  45.             i++;
  46.         }
  47.        
  48.     }
  49.     Dreptunghi(int x1, int x2, int y) : Linie(x1, x2) {
  50.         this->y = y;
  51.     }
  52. };
  53.  
  54.  
  55.  
  56. int main() {
  57.     Figura *pFig;
  58.      pFig = new Linie(10, 20);
  59.      pFig->deseneaza();
  60.      delete pFig;
  61.      pFig = new Dreptunghi(10, 49, 10);
  62.      pFig->deseneaza();
  63.      delete pFig;
  64.      system("pause");
  65.      return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement