SHARE
TWEET

Untitled

a guest Oct 13th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <chrono>
  3.  
  4. using namespace std;
  5.  
  6. class Square
  7. {
  8. protected:
  9.     int length;
  10. public:
  11.     Square(int a)
  12.     {
  13.         length = a;
  14.     }
  15.     void draw()
  16.     {
  17.         for(int i = 0; i < length; i++)
  18.         {
  19.             drawline();
  20.         }
  21.         cout << endl;
  22.     }
  23.    
  24.     void drawline()
  25.     {
  26.         for(int i = 0; i < length; i++)
  27.         {
  28.             cout << "*";
  29.         }
  30.         cout << endl;
  31.     }
  32. };
  33.  
  34. class Triangle : public Square
  35. {
  36.         int line;
  37. public:
  38.     Triangle(int a) : Square(a)
  39.     {
  40.         length = a;
  41.         line = a;
  42.     }
  43.     void draw()
  44.     {
  45.         for(int i = 0; i < line; i++)
  46.         {
  47.             drawline();
  48.             length -= 1;
  49.         }
  50.         cout << endl;
  51.     }
  52. };
  53.  
  54. class Rectangle : public Square
  55. {
  56.         int width;
  57. public:
  58.     Rectangle(int a, int b) : Square(a)
  59.     {
  60.         length = a;
  61.         width = b;
  62.     }
  63.     void draw()
  64.     {
  65.         for(int i = 0; i < width; i++)
  66.         {
  67.             drawline();
  68.         }
  69.         cout << endl;
  70.     }
  71. };
  72.  
  73. int main()
  74. {
  75.     Square A(5);
  76.     Triangle B(4);
  77.     Rectangle C(4,7);
  78.    
  79.     A.draw();
  80.     B.draw();
  81.     C.draw();
  82. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top