/** * This project is an attempt to build a program that could * draw a scene for us automatically, instead of requiring us to * point-and-click to create all of the shapes and move them around. * * @author Brad Richards * @version 1.0 */ public class House { private Square house; // Declare a variable called house private Triangle roof; /** * Constructor for objects of class House. Since this code is * called automatically when a House object is created, we can * put our scene-drawing code here. It'll run this sequence of * Java statements any time a House object is created. */ public House() { house = new Square(); // Store a new Square object in house house.makeVisible(); house.changeColor("blue"); house.slowMoveHorizontal(-100); roof = new Triangle(); roof.makeVisible(); roof.slowMoveVertical(-80); roof.slowMoveHorizontal(30); } /** * It would be nice to be able to move the entire house * to the right... */ public void moveRight() { house.moveRight(); roof.moveRight(); } /** * It would be nice to be able to move the entire house * to the right... */ public void moveRightMore() { house.moveHorizontal(50); roof.moveHorizontal(50); } public void moveBySpecifiedAmount(int howFar) { house.moveHorizontal(howFar); roof.moveHorizontal(howFar); } }