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.
Shape.cpp@2:0224a34c9243, 2019-08-08 (annotated)
- Committer:
- kaushalpkk
- Date:
- Thu Aug 08 18:47:28 2019 +0000
- Revision:
- 2:0224a34c9243
- Parent:
- 0:0bd684b9e2c3
added double stars to comments
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kaushalpkk | 0:0bd684b9e2c3 | 1 | #include "mbed.h" |
| kaushalpkk | 0:0bd684b9e2c3 | 2 | #include "Shape.h" |
| kaushalpkk | 0:0bd684b9e2c3 | 3 | |
| kaushalpkk | 0:0bd684b9e2c3 | 4 | Shape::Shape(int x){ |
| kaushalpkk | 0:0bd684b9e2c3 | 5 | _x = x; |
| kaushalpkk | 0:0bd684b9e2c3 | 6 | _y = -1; |
| kaushalpkk | 0:0bd684b9e2c3 | 7 | } |
| kaushalpkk | 0:0bd684b9e2c3 | 8 | |
| kaushalpkk | 0:0bd684b9e2c3 | 9 | Shape::Shape(int x, int y){ |
| kaushalpkk | 0:0bd684b9e2c3 | 10 | _x = x; |
| kaushalpkk | 0:0bd684b9e2c3 | 11 | _y = y; |
| kaushalpkk | 0:0bd684b9e2c3 | 12 | } |
| kaushalpkk | 0:0bd684b9e2c3 | 13 | int Shape::getArea(){ |
| kaushalpkk | 0:0bd684b9e2c3 | 14 | if(_y == -1) |
| kaushalpkk | 0:0bd684b9e2c3 | 15 | return (_x * _x); |
| kaushalpkk | 0:0bd684b9e2c3 | 16 | else |
| kaushalpkk | 0:0bd684b9e2c3 | 17 | return (_x * _y); |
| kaushalpkk | 0:0bd684b9e2c3 | 18 | } |
| kaushalpkk | 0:0bd684b9e2c3 | 19 | |
| kaushalpkk | 0:0bd684b9e2c3 | 20 | int Shape::getPerimeter(){ |
| kaushalpkk | 0:0bd684b9e2c3 | 21 | if(_y == -1) |
| kaushalpkk | 0:0bd684b9e2c3 | 22 | return (_x * 4 ); |
| kaushalpkk | 0:0bd684b9e2c3 | 23 | else |
| kaushalpkk | 0:0bd684b9e2c3 | 24 | return (2 * (_x + _y)); |
| kaushalpkk | 0:0bd684b9e2c3 | 25 | } |