User Tools

Site Tools


milewalker

This is an old revision of the document!


MileWalker.java

import kareltherobot.*;
 
public class MileWalker extends Robot               
// note the capital letters for the class name
{					       
	public MileWalker(int street, int avenue, 
                          Direction direction, int beepers) 
	{
		super(street, avenue, direction, beepers);
	}
 
        public void moveMile()
	{							
            move(); move(); move(); move();  // one line to conserve space
            move(); move(); move(); move();	 
	}                                                                  
// note the robot name is not used
}

MileWalkerRunner

task()
{	
       MileWalker lisa = new MileWalker (3, 2, East, 0);       // declare a MileWalker robot
       lisa.moveMile();			 // call the new method
       lisa.pickBeeper();	         // call an old method
       lisa.turnLeft();
        lisa.move();
	lisa.pickBeeper();
	lisa.moveMile();
	lisa.turnOff();
}
milewalker.1566567114.txt.gz · Last modified: 2019/08/23 09:31 by frchris