...

Committer:
kaushalpkk
Date:
Thu Aug 08 18:47:28 2019 +0000
Revision:
2:0224a34c9243
Parent:
1:2bc647d6c00d
added double stars to comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kaushalpkk 0:0bd684b9e2c3 1 #ifndef MY_SHAPE
kaushalpkk 0:0bd684b9e2c3 2 #define MY_SHAPE
kaushalpkk 0:0bd684b9e2c3 3
kaushalpkk 0:0bd684b9e2c3 4 #include "mbed.h"
kaushalpkk 0:0bd684b9e2c3 5
kaushalpkk 2:0224a34c9243 6 /**
kaushalpkk 2:0224a34c9243 7 * A library to create square and rectangle objects. calculates the area and perimeter
kaushalpkk 2:0224a34c9243 8 *
kaushalpkk 2:0224a34c9243 9 * Example:
kaushalpkk 2:0224a34c9243 10 * @code
kaushalpkk 2:0224a34c9243 11 *
kaushalpkk 2:0224a34c9243 12 * #include "mbed.h"
kaushalpkk 2:0224a34c9243 13 * #include "Shape.h"
kaushalpkk 2:0224a34c9243 14 *
kaushalpkk 2:0224a34c9243 15 * Shape rect(3,4);
kaushalpkk 2:0224a34c9243 16 * Shape squr(1);
kaushalpkk 2:0224a34c9243 17 *
kaushalpkk 2:0224a34c9243 18 * int main() {
kaushalpkk 2:0224a34c9243 19 * printf(" area of rect = %d \n", rect.getArea());
kaushalpkk 2:0224a34c9243 20 * printf("perimeter of square = %d \n", squr.getPerimeter());
kaushalpkk 2:0224a34c9243 21 * }
kaushalpkk 2:0224a34c9243 22 *
kaushalpkk 2:0224a34c9243 23 * @endcode
kaushalpkk 2:0224a34c9243 24 *
kaushalpkk 1:2bc647d6c00d 25 */
kaushalpkk 1:2bc647d6c00d 26
kaushalpkk 0:0bd684b9e2c3 27 class Shape{
kaushalpkk 0:0bd684b9e2c3 28 public:
kaushalpkk 2:0224a34c9243 29 /** create an object for square
kaushalpkk 1:2bc647d6c00d 30 * @param x integer value for a side on square
kaushalpkk 1:2bc647d6c00d 31 */
kaushalpkk 1:2bc647d6c00d 32 Shape(int x);
kaushalpkk 1:2bc647d6c00d 33
kaushalpkk 1:2bc647d6c00d 34
kaushalpkk 2:0224a34c9243 35 /** create an object for rectangle
kaushalpkk 1:2bc647d6c00d 36 * @param x integer value for length of rectangle
kaushalpkk 1:2bc647d6c00d 37 * @param y integer value for breadth of rectangle
kaushalpkk 1:2bc647d6c00d 38 */
kaushalpkk 1:2bc647d6c00d 39 Shape(int x, int y);
kaushalpkk 1:2bc647d6c00d 40
kaushalpkk 2:0224a34c9243 41 /** returns to area of rectangle/square
kaushalpkk 1:2bc647d6c00d 42 * @return returns the area of rectangle/square
kaushalpkk 1:2bc647d6c00d 43 */
kaushalpkk 0:0bd684b9e2c3 44 int getArea();
kaushalpkk 1:2bc647d6c00d 45
kaushalpkk 1:2bc647d6c00d 46
kaushalpkk 2:0224a34c9243 47 /** returns to perimeter of rectangle/square
kaushalpkk 1:2bc647d6c00d 48 * @return returns the perimeter of rectangle/square
kaushalpkk 1:2bc647d6c00d 49 */
kaushalpkk 0:0bd684b9e2c3 50 int getPerimeter();
kaushalpkk 1:2bc647d6c00d 51
kaushalpkk 0:0bd684b9e2c3 52 private:
kaushalpkk 0:0bd684b9e2c3 53 int _x;
kaushalpkk 0:0bd684b9e2c3 54 int _y;
kaushalpkk 0:0bd684b9e2c3 55 int _area;
kaushalpkk 0:0bd684b9e2c3 56 int _perim;
kaushalpkk 0:0bd684b9e2c3 57 };
kaushalpkk 0:0bd684b9e2c3 58
kaushalpkk 0:0bd684b9e2c3 59 #endif