All pastes #1832067 Raw Edit

Unnamed

public text v1 · immutable
#1832067 ·published 2010-03-10 16:41 UTC
rendered paste body
import becker.robots.*;

/**
	This application programs a Robot to pick up lights on a street and move them one block to the east.
*/
public class StreetRepaving
{
	public static void main(String[] args)
	{
		City vancouver = new City();
		Robot lightMover = new Robot(vancouver, 0, 2, Directions.EAST);
		
		// Here's where we create flashing lights on 2nd Street.
		// The last parameter turns the flashing light on.
		Flasher flash1 = new Flasher(vancouver, 2, 2, true);
		Flasher flash2 = new Flasher(vancouver, 4, 2, true);
		
		CityFrame frame = new CityFrame(vancouver);
		
		// Program the lightMover Robot to move the lights.  
		lightMover.move();
		int i = 0;
		while (i <= 3)
		{
			if (lightMover.isBesideThing())
			{
				lightMover.pickThing();
				lightMover.move();
				lightMover.putThing();
				lightMover.move();
				i += 2;
			}
			else
			{
				lightMover.move();
				i++;
			}
		}
    }
}