Ejemplo n.º 1
0
        // 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;
        }
Ejemplo n.º 2
0
 public override void VisitCylider(Cylinder cylinder)
 {
     amount++;
 }
Ejemplo n.º 3
0
 public abstract void VisitCylider(Cylinder cylinder);