import cs1705.*; // ------------------------------------------------------------------------- /** * This robot adds extra behaviors to a NavigatorBot so that it can trace * copy patterns at the request of a StencilBot. * * @author Stephen Edwards * @version 2003.09.21 */ public class CopierBot extends NavigatorBot { //~ Variables ............................................................. int streetOrigin; int avenueOrigin; //~ Constructors .......................................................... // ---------------------------------------------------------- /** * Construct a stencil robot by specifying its starting state. * The parameters are just passed to the corresponding NavigatorBot * constructor. */ public CopierBot( int street, int avenue, Direction facing, int numBeepers ) { super( street, avenue, facing, numBeepers ); streetOrigin = street; avenueOrigin = avenue; } //~ Methods ............................................................... // ---------------------------------------------------------- /** * Move to the specified intersection. * * @param street the street number of the destination * @param avenue the avenue number of the destination */ public void moveTo( int street, int avenue ) { super.moveTo( streetOrigin + 2 * street, avenueOrigin + 2 * avenue ); } // ---------------------------------------------------------- /** * Place beepers on 4 corners in a square. */ public void putBeeper() { int count = 4; faceNorth(); while ( count > 0 ) { super.putBeeper(); turnLeft(); move(); count--; } } }