class Rect
{
int x, y, w, h;

Rect ( int xx, int yy, int ww, int hh )
{
x = xx; y = yy;
w = ww; h = hh;
}

boolean intersects ( Rect r )
{
// for positive values of w and h only.
// you have to check and flip values if they might be negative.
//

return !( x > r.x+r.w || x+w < r.x || y > r.y+r.h || y+h < r.y );
}
}