using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace F2
{
    class Program
    {
        static void Main(string[] args)
        {
            Dimension[] array = new Dimension[] {
                new Rechteck(2, 3),
                new Quadrat(2),
                new Wuerfel(4),
                new Kreis(1),
                new Kugel(1),
                new Zylinder(1,3)
            };
            foreach (Dimension d in array)
                Console.WriteLine(d.FlaecheBerechnen());
            Console.ReadLine();
        }
    }

    abstract class Dimension
    {
        #region Properties
        private int x;
        public int X
        {
            get
            {
                return x;
            }
            set
            {
                x = value;
            }
        }

        private int y;
        public int Y
        {
            get
            {
                return y;
            }
            set
            {
                y = value;
            }
        }
        #endregion

        abstract public double FlaecheBerechnen();
    }

    class Rechteck : Dimension
    {
        public Rechteck(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }

        public override double FlaecheBerechnen()
        {
            return X * Y;
        }
    }

    class Quadrat : Rechteck
    {
        public Quadrat(int x) : base(x, x) { }
    }

    class Wuerfel : Quadrat
    {
        public Wuerfel(int x) : base(x) { }

        public override double FlaecheBerechnen()
        {
            return X * base.FlaecheBerechnen();
        }
    }

    class Kreis : Rechteck
    {
        public Kreis(int r) : base(r, r) { }

        public override double FlaecheBerechnen()
        {
            return 2 * Math.PI * X * X;
        }
    }

    class Kugel : Kreis
    {
        public Kugel(int r) : base(r) { }

        public override double FlaecheBerechnen()
        {
            return 2 * base.FlaecheBerechnen();
        }
    }

    class Zylinder : Kreis
    {
        public Zylinder(int r, int h) : base(r)
        {
            Y = h;
        }

        public override double FlaecheBerechnen()
        {
            return base.FlaecheBerechnen() + 2 * X * Y * Math.PI;
        }
    }
}
