import com.seanhandley.projects.BinaryTree.IVisitor; /** * * Visitor object for a car. * * @author Sean Handley, 320097@swan.ac.uk * @version May 2007 */ public class CarVisitor1 implements IVisitor<Car,String> { private boolean found = false; private String reg = ""; /** * Find first car's registration number with weight 4000 */ public String node(Car car) { //see if a car of weight 4000 exists if(!found) { if(car.weight == 4000) { found = true; reg = car.registration; return reg; } else { return "not found"; } } else { return reg; } } }