...
Diff: Shape.h
- Revision:
- 1:2bc647d6c00d
- Parent:
- 0:0bd684b9e2c3
- Child:
- 2:0224a34c9243
--- a/Shape.h Thu Aug 08 18:32:59 2019 +0000 +++ b/Shape.h Thu Aug 08 18:44:24 2019 +0000 @@ -3,12 +3,52 @@ #include "mbed.h" +/* +A library to create square and rectangle objects. calculates the area and perimeter + +Example: +@code + +#include "mbed.h" +#include "Shape.h" + +Shape rect(3,4); +Shape squr(1); + +int main() { + printf(" area of rect = %d \n", rect.getArea()); + printf("perimeter of square = %d \n", squr.getPerimeter()); +} + +@endcode + +*/ + class Shape{ public: - Shape(int); - Shape(int, int); + /* create an object for square + * @param x integer value for a side on square + */ + Shape(int x); + + + /* create an object for rectangle + * @param x integer value for length of rectangle + * @param y integer value for breadth of rectangle + */ + Shape(int x, int y); + + /* returns to area of rectangle/square + * @return returns the area of rectangle/square + */ int getArea(); + + + /* returns to perimeter of rectangle/square + * @return returns the perimeter of rectangle/square + */ int getPerimeter(); + private: int _x; int _y;