...
Shape.cpp
- Committer:
- kaushalpkk
- Date:
- 2019-08-08
- Revision:
- 2:0224a34c9243
- Parent:
- 0:0bd684b9e2c3
File content as of revision 2:0224a34c9243:
#include "mbed.h"
#include "Shape.h"
Shape::Shape(int x){
_x = x;
_y = -1;
}
Shape::Shape(int x, int y){
_x = x;
_y = y;
}
int Shape::getArea(){
if(_y == -1)
return (_x * _x);
else
return (_x * _y);
}
int Shape::getPerimeter(){
if(_y == -1)
return (_x * 4 );
else
return (2 * (_x + _y));
}