/* mRectangle.java */ import java.awt.*; public class mRectangle extends mPoint { int w, h; public mRectangle(int _x, int _y, int _w, int _h) { /* call mPoint's constructor */ super(_x, _y); /* initial w and h */ w = _w; h = _h; } /* check if position inside object */ public boolean isInside(int _x, int _y) { return (x <= _x) && (_x < x+w) && (y <= _y) && (_y < y+h); } public void paint(Graphics g) { /* draw rectangle */ g.setColor(color); g.fillRect(x, y, w, h); } }