srecord Rect(int x, int y, int w, int h) is WidthAndHeight { *(Rectangle r) { x = r.x; y = r.y; w = r.width; h = r.height; } *(Pt p, int *w, int *h) { x = p.x; y = p.y; } *(Rect r) { x = r.x; y = r.y; w = r.w; h = r.h; } final Rectangle getRectangle() { ret new Rectangle(x, y, w, h); } public S toString() { ret x + "," + y + " / " + w + "," + h; } final int x1() { ret x; } final int y1() { ret y; } final int x2() { ret x + w; } final int y2() { ret y + h; } final bool contains(Pt p) { ret contains(p.x, p.y); } final bool contains(int _x, int _y) { ret _x >= x && _y >= y && _x < x+w && _y < y+h; } final bool contains(Rectangle r) { ret rectContains(this, r); } final bool empty() { ret w <= 0 || h <= 0; } final public int getWidth() { ret w; } final public int getHeight() { ret h; } final public int area() { ret w*h; } final public int x() { ret x; } final public int y() { ret y; } WidthAndHeight widthAndHeight() { ret main widthAndHeight(w, h); } }