import java.awt.*; import java.applet.Applet; public class House3 extends Applet { public void paint(Graphics g){ drawHouse(g, 50, 100, 100, 100, Color.red, Color.blue); drawHouse(g,200, 100, 100, 150, Color.green, Color.yellow); drawHouse(g, 200, 300, 150, 50, Color.cyan, Color.magenta); } public void drawHouse(Graphics g, int x, int y, int width, int height, Color houseClr, Color roofClr){ Polygon roof = new Polygon(); roof.addPoint(x, y); roof.addPoint(x + width/2, y - height/2); roof.addPoint(x + width, y); roof.addPoint(x, y); g.setColor(houseClr); g.fillRect(x, y, width, height); g.setColor(roofClr); g.fillPolygon(roof); } }