Rectangle class
Dependents: FollowMeBot FollowMeBot FollowMeBot3 FollowMeBot
Fork of Rectangle by
Diff: Rectangle.cpp
- Revision:
- 1:d9c0709ba2ce
- Parent:
- 0:19fca77774b6
- Child:
- 2:087e0b0b526c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Rectangle.cpp Mon Nov 18 21:09:00 2013 +0000 @@ -0,0 +1,42 @@ +#include "mbed.h" +#include "Rectangle.h" + + +Rectangle :: Rectangle(int x,int y, int xx, int yy){ + x1 = x; + x2 = xx; + y1 = y; + y2 = yy; + } + +bool Rectangle :: is_touch(int x_touch , int y_touch){ + if(x_touch >= x1 && x_touch <= x2) + if(y_touch >= y1 && y_touch <= y2) + return true; + return false; + } + + +int Rectangle :: getX1(){ + return x1; + } + +int Rectangle :: getX2(){ + return x2; + } + +int Rectangle :: getY1(){ + return y1; + } + +int Rectangle :: getY2(){ + return y2; + } + +int Rectangle :: getCenterX(){ + return x1 + (x2-x1)/2; + } + +int Rectangle :: getCenterY(){ + return y1 + (y2-y1)/2; + } \ No newline at end of file