SHARE
TWEET

Untitled

a guest Oct 13th, 2019 90 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.     int width;
  11.     int line;
  12. public:
  13.     Square(int a)
  14.     {
  15.         length = a;
  16.         width = a;
  17.         line = 0;
  18.     }
  19.     void draw()
  20.     {
  21.         for(int i = 0; i < width; i++)
  22.         {
  23.             drawline();
  24.         }
  25.         cout << endl;
  26.     }
  27.    
  28.     void drawline()
  29.     {
  30.         for(int i = 0; i < length; i++)
  31.         {
  32.             cout << "*";
  33.         }
  34.         cout << endl;
  35.     }
  36. };
  37.  
  38. class Triangle : public Square
  39. {
  40. public:
  41.     Triangle(int a) : Square(a)
  42.     {
  43.         length = a;
  44.         line = a;
  45.     }
  46.     void draw()
  47.     {
  48.         for(int i = 0; i < line; i++)
  49.         {
  50.             drawline();
  51.             length -= 1;
  52.         }
  53.         cout << endl;
  54.     }
  55. };
  56.  
  57. class Rectangle : public Square
  58. {
  59. public:
  60.     Rectangle(int a, int b) : Square(a)
  61.     {
  62.         length = a;
  63.         width = b;
  64.     }
  65.     void draw()
  66.     {
  67.         for(int i = 0; i < width; i++)
  68.         {
  69.             drawline();
  70.         }
  71.         cout << endl;
  72.     }
  73. };
  74.  
  75. int main()
  76. {
  77.     Square A(5);
  78.     Triangle B(4);
  79.     Rectangle C(4,7);
  80.    
  81.     A.draw();
  82.     B.draw();
  83.     C.draw();
  84. }
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