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

namespace ConsoleApplication16
{
    class Program
    {
        static void Main(string[] args)
        {
            Predmet x = new Kvadar(1, 2, 3);
            //    Kvadar k = (Kvadar)new Predmet();
            Kvadar k2 = (Kvadar)x;

            Console.WriteLine(k2.velikaDijagnala());

         //   Predmet p = new Predmet();
            Console.ReadLine();
            Lopta y = new Lopta(5);
            Predmet[] niz = new Predmet[3];
            niz[0] = new Kvadar(1, 2, 3);
            niz[1] = new Lopta(3);
            niz[2] = new Kvadar(3, 2, 2);
            foreach (var n in niz)
                Console.WriteLine(n.zapremina());
            Console.WriteLine(x);
            Console.WriteLine(x.zapremina());
            Console.WriteLine(x.povrsina());
            Console.WriteLine(y.ToString());
            Console.WriteLine(y.zapremina());
            Console.WriteLine(y.povrsina());
            Console.ReadKey();
        }
    }

    abstract class Predmet
    {
        static int count = 0;
        int id;

        public Predmet()
        {
            count++;
            id = count;
        }

        public int ID
        {
            get
            {
                return id;
            }
        }

        public abstract double zapremina();

        public double povrsina()
        {
            return 0;
        }
    }

    class Kvadar : Predmet
    {
        int a; int b; int c;

        public Kvadar(int x, int y, int z) { a = x; b = y; c = z; }
        public override double zapremina() { return a * b * c; }
        public double povrsina() { return 2 * (a * b + a * c + b * c); }
        public override string ToString() { return "Kvadar_" + ID; }
        public double velikaDijagnala() { return 13; }
    }

    class Lopta : Predmet
    {
        int r;

        public Lopta(int x) { r = x; }
        public double zapremina() { return 4.0 / 3 * Math.Pow(r, 3) * Math.PI; }
        public double povrsina() { return 4 * Math.Pow(r, 2) * Math.PI; }
        public string ToString() { return "Lopta_" + ID; }
    }
}
