コード例 #1
0
ファイル: Program.cs プロジェクト: lastachkin/OOP_labour
        static void Main(string[] args)
        {
            var pasPlane     = new PassangerPlane(500, "Airplane");
            var militarPlane = new MilitaryPlane(2000, true, "F15");
            var boeingPlane  = new Boeing(9, 450, "SARL 0ER5");
            var plane        = new TU134(15, 250, "AR 220");

            pasPlane.Display();

            var newPasPlane = pasPlane as Aviation;

            if (newPasPlane != null)
            {
                Console.WriteLine("Я преобразован в Aviation");
            }
            else
            {
                Console.WriteLine("Ooops!");
            }

            if (militarPlane is Aviation)
            {
                Console.WriteLine("Объект может быть преобразован в тип Aviation");
            }
            else
            {
                Console.WriteLine("militarPlane ne может быть преобразован в тип Aviation");
            }

            ((IName1)plane).GetName();
            ((IName2)plane).GetName();

            Print.IamPrinting(pasPlane);
            Print.IamPrinting(plane);
            //End of 5lab.

            //6 lab has been started
            Container <Aviation> contain = new Container <Aviation>();

            contain.add(new PassangerPlane(480, "Airbus A370"));
            contain.add(new PassangerPlane(100, "YAK 40"));
            contain.add(new Boeing(15, 400, "Boeing 747"));
            contain.add(new TU134(20, 145, "TU_134"));
            contain.add(new MilitaryPlane(750, true, "F15"));
            contain.add(new MilitaryPlane(900, true, "Eurofighter"));

            Controller.GenerallPasCapacity(contain);
            Controller.SortingByDescending(contain);

            Console.ReadKey();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: lastachkin/OOP_labour
 int this[int i]
 {
     get
     {
         if (arr[i] is PassangerPlane)
         {
             PassangerPlane x = arr[i] as PassangerPlane;
             return(x.passangerCapacity);
         }
         else
         {
             CargoPlane y = arr[i] as CargoPlane;
             return(y.carrying);
         }
     }
 }