1  /* mCircle.java */

  2  

  3  import java.awt.*;

  4  

  5  public class mTriangle extends mRectangle {

  6    public mTriangle(int _x, int _y, int _w, int _h) {

  7      /* call mRectangle's constructor */

  8      super(_x, _y, _w, _h);

  9    }

 10    public void paint(Graphics g) {

 11      /* draw triangle */

 12      int xx[] = { x, x+w, x+w/2};

 13      int yy[] = { y+h, y+h, y};

 14      g.setColor(color);

 15      g.fillPolygon(xx, yy, 3);

 16    }

 17  }