// Use this for initialization void Start() { Sphere sphere = new Sphere(); Cylinder cylinder = new Cylinder(); Cube cube1 = new Cube(); Cube cube2 = new Cube(); ShapeContainer container = new ShapeContainer(); container.AddShape(sphere); container.AddShape(cylinder); container.AddShape(cube1); container.AddShape(cube2); AmountVisitor amountVisitor = new AmountVisitor(); container.RunVisitor(amountVisitor); int amount = amountVisitor.amount; }
public override void VisitCylider(Cylinder cylinder) { amount++; }
public abstract void VisitCylider(Cylinder cylinder);