using System;

public class PerimeterVisitor: Visitor
{
  private double totalPerimeter;

  public double Perimeter
  {
    get { return totalPerimeter; }
  }

  public override void visit(Circle c)
  {
    if (c == null) return;
    totalPerimeter += Math.PI * 2.0 * c.Radius;
  }

  public override void visit(Rectangle r)
  {
    if (r == null) return;
    totalPerimeter += (double) 2 * (r.Width + r.Height);
  }
}
