/* * AP(r) Computer Science GridWorld Case Study: * Copyright(c) 2005-2006 Cay S. Horstmann (http://horstmann.com) * * This code is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * @author Cay Horstmann * @author Chris Nevison * @author Barbara Wells */ import java.awt.Color; import info.gridworld.actor.Actor; import info.gridworld.actor.Bug; import info.gridworld.grid.Location; public class Candle extends Actor { boolean east = true; public Candle() { setColor(Color.RED); } public void act() { if (east) moveTo(getLocation().getNeighborLocation(Location.EAST)); else moveTo(getLocation().getNeighborLocation(Location.WEST)); east = !east; } }