Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Shape.cpp
- Revision:
- 0:0bd684b9e2c3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Shape.cpp Thu Aug 08 18:32:59 2019 +0000
@@ -0,0 +1,25 @@
+#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));
+}
\ No newline at end of file