Esempio n. 1
0
    public static void Main(String[] args)
    {
        Vessel v1 = new Barrel(3, 10);
        Vessel v2 = new Tank(10, 20, 12);
        Vessel v3 = new Cube(4);

        Vessel[] vs = { v1, v2, v3 };
        v1.Fill(90); v1.Fill(10); v2.Fill(100); v3.Fill(80);
        double sum = 0;

        for (int i = 0; i < vs.Length; i++)
        {
            sum += vs[i].Capacity();
        }
        Console.WriteLine("Total capacity is " + sum);
        sum = 0;
        for (int i = 0; i < vs.Length; i++)
        {
            sum += vs[i].Contents;
        }
        Console.WriteLine("Total contents is " + sum);
        for (int i = 0; i < vs.Length; i++)
        {
            Console.WriteLine("vessel number " + i + ": " + vs[i]);
        }
    }