import java.awt.*; import java.applet.Applet; public class Houses extends Applet { Graphics g; // used in all methods so make it an instance variable once we get it from paint public void paint(Graphics g) { this.g = g; // make g an instance variable so we do not need to pass it around anymore drawHouse(50, 50, 70, 30); drawHouse(100, 50, 60, 20); } private void drawTriangle(int bottomX, int bottomY, int base, int height){ // no more Graphics g parameter needed g.drawLine(bottomX, bottomY, bottomX+base, bottomY); g.drawLine(bottomX+base, bottomY, bottomX+base/2, bottomY-height); g.drawLine(bottomX+base/2, bottomY-height, bottomX, bottomY); } private void drawHouse(int bottomX, int bottomY, int width, int height){ // no more Graphics g parameter needed g.drawRect(bottomX, bottomY-height, width, height); this.drawTriangle(bottomX, bottomY-height, width, height/2); } }