1 /* mTriangle.java */ 2 3 import java.awt.*; 4 5 public class mTriangle extends mRectangle { 6 7 public mTriangle(int _x, int _y, int _w, int _h) { 8 /* call mRectangle's constructor */ 9 super(_x, _y, _w, _h); 10 } 11 12 public void paint(Graphics g) { 13 /* draw triangle */ 14 int xx[] = { x, x+w, x+w/2}; 15 int yy[] = { y+h, y+h, y}; 16 g.setColor(color); 17 g.fillPolygon(xx, yy, 3); 18 } 19 20 }