/* * Filename: MyYard.java * Created on Feb 14, 2006 * * Course: ITK 168 * Semester: Spring 06 * */ import becker.robots.*; /** * @author Shirley White * * This is a subclass of RectangleCity, which is a subclass of becker.City. * * This class creates a completely fenced in yard with a house * that faces south. * The house sits on the back of the lot - joining the back fence. * There is a single door in the front of the house facing south. * * There are a number of dandelions in the west yard - none in front or the * in the east yard - there is no back yard. * The northwest corner of the yard is always (1, 1). * * There are are a number of constants created to setup the elements. * Their values may be changed to vary the yard layout. */ public class MyYard extends RectangleCity { public static final int YARD_HT = 10; //The height of the yard public static final int YARD_WD = 20; //The width of the yard //The avenue number of the inside northwest corner of the house // This must be an odd number for even num columns in west yard public static final int HOUSE_AV = 7; public static final int HOUSE_HT = 5; //The height of the house public static final int HOUSE_WD = 7; //The width of the house public static final int TO_DOOR = 5; //The distance from SW corner to the door public static final int FLOWERS = 100;//Number of dandelions in the yard /** * The number of visible streets is set to 13 and the number of * visible avenues is set to 22. */ public MyYard() { super(13, 22); // draw fence this.makeRectangle(1, 1, this.YARD_HT, MyYard.YARD_WD); // draw house leaving door on south wall this.makeVertWall(1, MyYard.HOUSE_AV, MyYard.HOUSE_HT, Direction.WEST); this.makeVertWall(1, MyYard.HOUSE_AV + MyYard.HOUSE_WD, MyYard.HOUSE_HT, Direction.EAST); this.makeHorizWall(MyYard.HOUSE_HT, MyYard.HOUSE_AV, MyYard.TO_DOOR, Direction.SOUTH); this.makeHorizWall(MyYard.HOUSE_HT, MyYard.HOUSE_AV + MyYard.TO_DOOR + 1, MyYard.HOUSE_WD - MyYard.TO_DOOR, Direction.SOUTH); // place random dandalions in the west yard this.randomFlowers(); } /** * Places flowers (Things) in random locations throughout the given rectangle. * It is possible for multiple flowers to be placed on the same intersection. */ public void randomFlowers() { int randSt; int randAv; for(int i=0; i