using System;

public class TestVisitor
{
  private static Shape[] buildShapes()
  {
    Shape[] s = new Shape[5];
    s[0] = new Rectangle(0, 0, 10, 20);
    s[1] = new Circle(10, 10, 7);
    s[2] = new Rectangle(5, 2, 5, 5);
    s[3] = new Circle(2, 17, 4);
    s[4] = new Rectangle(1, -2, 5, 9);
    return s;
  }

  public static void Main(string[] args)
  {
    Visitor v = new SurfaceVisitor();
    Shape[] s = buildShapes();

    for (int i = 0; i < s.Length; i++)
    {
      v.visit(s[i] as Circle);
      v.visit(s[i] as Rectangle);
    }
    Console.WriteLine("La surface totale est de : " + (v as SurfaceVisitor).Surface);

    v = new PerimeterVisitor();
    for (int i = 0; i < s.Length; i++)
    {
      v.visit(s[i] as Circle);
      v.visit(s[i] as Rectangle);
    }
    Console.WriteLine("Le périmètre totale est de : " + (v as PerimeterVisitor).Perimeter);
  }
}
