warfighter67

lab7

Oct 29th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include "rectangle.h"
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. rectangle::rectangle()
  7. {
  8.     this->description="I am a rectangle";
  9. }
  10.  
  11. rectangle::rectangle(string desIn, int hIn, int wIn)
  12. {
  13.     this->description=desIn;
  14.     height = hIn;
  15.     width = wIn;
  16. }
  17.  
  18. void rectangle::set(int hIn, int wIn)
  19. {
  20.     height = hIn;
  21.     width = wIn;
  22. }
  23. void rectangle::draw()
  24. {
  25.     for(int x = 0; x < height; x++)
  26.     {
  27.         for(int y = 0; y < width; y++)
  28.         {
  29.             if(x == 0 || x == height - 1 || y == 0 || y == width - 1)
  30.             {
  31.                 cout << "+ ";
  32.             }
  33.             else
  34.             {
  35.                 cout << "  ";
  36.             }
  37.         }
  38.         cout << endl;
  39.     }
  40. }
  41. float rectangle::getArea()
  42. {
  43.     return height * width;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment