当前位置: 首页>>代码示例>>C#>>正文


C# Car.start方法代码示例

本文整理汇总了C#中Car.start方法的典型用法代码示例。如果您正苦于以下问题:C# Car.start方法的具体用法?C# Car.start怎么用?C# Car.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Car的用法示例。


在下文中一共展示了Car.start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: run

        static void run()
        {
            Vehicle vehicle;
            //Vehicule is an abstract class
            //vehicule = new Vehicule("diesel",150);
            //vehicule = new Vehicule();
            //by inheritance, vehicule gets public behaviours of its mother class
            //Console.WriteLine(vehicule.ToString());
            //vehicule.start();

            Plane plane = new Plane("kerosene",540,8000);
            plane.Speed = 540;
            plane.Fuel = "Kerosene";
            plane.start();
            plane.climb();
            plane.descend();
            plane.accelerate();
            plane.brake();

            Car car = new Car("diesel", 196, 120);
            car.start();
            car.drive();
            car.accelerate();
            car.brake();
            vehicle = car; //after that, only public members of the vehicle class can be accessed . we lose accessibility to car members
            vehicle.start(); //if start has redefinition in child classes so child method will be called too
            ((Car)vehicle).drive(); // restore the view of the object through a car
            //always test the type before value cast 'conversion)
            if (vehicle is Plane)
            {
                ((Plane)vehicle).climb();
                Plane p = (Plane)vehicle;
                p.climb();
                Plane p2 = vehicle as Plane;
                p2.climb();
            }

            Vehicle[] vehicles = new Vehicle[10];
            vehicles[0] = car;
            vehicles[1] = plane;

            Car[] cars = new Car[10];
            cars[0] = new Car("diesel", 196, 120);
            cars[0].Quotation = 150;
            cars[0].Quotation = 100;
            cars[0].isRising();
            cars[1] = new Car("diesel", 196, 90);
            cars[2] = new Car("diesel", 196, 20);
            cars[3] = new Car("super", 196, 250);
            cars[4] = new Car("nitro", 196, 1000);
            cars[5] = new Car("diesel", 196, 154);
            cars[6] = new Car("super", 196, 157);

            ICotable[] cotables = new ICotable[3];
            cotables[0] = new Artwork();
            cotables[0].Quotation = 150000;
            cotables[0].Quotation = 145000;

            cotables[1] = cars[0];

            int[] integers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 5, 4, 8, 6, 3, 9, 7 };
            Array.Sort(integers);
            foreach (int i in integers)
                Debug.WriteLine(i);

            Array.Sort(cars);
        }
开发者ID:NivekAlunya,项目名称:csharp,代码行数:67,代码来源:Program.cs


注:本文中的Car.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。