import java.awt.*; /** * A simple class to draw a picture of a house * * @author Ben Dugan * @author Hal Perkins * @version 6/25/01 */ public class House { /** Create a new window and draw a picture of a house in it */ public void drawHouse( ) { // Make a new Graphics window GWindow theWindow = new GWindow(); // Define house coordinates and dimensions int frameX = 50; // lower left x of the walls int frameY = 200; // lower left y of the walls int wallWidth = 150; int wallHeight = 100; int roofWidth = 200; int roofHeight = 50; int overhang = roofWidth - wallWidth; int roofBaseY = frameY - wallHeight; // Make the basic frame of the house theWindow.add(new Rectangle(frameX, roofBaseY, wallWidth, wallHeight)); theWindow.add(new Triangle(frameX-overhang, roofBaseY, frameX + wallWidth + overhang, roofBaseY, frameX + (wallWidth/2), roofBaseY - roofHeight, Color.red, true)); } }