public object visit(vegetable v) { if (v.Calories < min.Calories) { min = v; } return(v.nextitem.accept(this)); }
public object visit(vegetable v) { if (state == "fruit" || state == "vegetable") { state = "vegetable"; return(v.nextitem.accept(this)); } else { return(false); } }
public object visit(vegetable v) { Console.Write("I hate vegetables! "); if (v.name == "spinach") { Console.WriteLine("Except spinach!"); cals += v.Calories; } else { Console.WriteLine("I won't eat " + v.name); } if (cals < max) { return(v.nextitem.accept(this)); } else { return(cals); } }
public object visit(vegetable v) { foodSum += v.Calories; return(v.nextitem.accept(this)); }