Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "rectangle.h"
- #include <string>
- #include <iostream>
- using namespace std;
- rectangle::rectangle()
- {
- this->description="I am a rectangle";
- }
- rectangle::rectangle(string desIn, int hIn, int wIn)
- {
- this->description=desIn;
- height = hIn;
- width = wIn;
- }
- void rectangle::set(int hIn, int wIn)
- {
- height = hIn;
- width = wIn;
- }
- void rectangle::draw()
- {
- for(int x = 0; x < height; x++)
- {
- for(int y = 0; y < width; y++)
- {
- if(x == 0 || x == height - 1 || y == 0 || y == width - 1)
- {
- cout << "+ ";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- }
- float rectangle::getArea()
- {
- return height * width;
- }
Advertisement
Add Comment
Please, Sign In to add comment