Rectangle class

Dependents:   FollowMeBot FollowMeBot FollowMeBot3 FollowMeBot

Fork of Rectangle by Sensovery Company

Rectangle.cpp

Committer:
dhamilton31
Date:
2013-11-18
Revision:
1:d9c0709ba2ce
Parent:
main.cpp@ 0:19fca77774b6
Child:
2:087e0b0b526c

File content as of revision 1:d9c0709ba2ce:

#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;
    }