コード例 #1
0
        static void Main(string[] args)
        {
            Vehicle MyVehicle = new Vehicle();

            MyVehicle.MainColor        = "Neon Pink";
            MyVehicle.MaximumOccupancy = "6";

            Tesla MyTesla = new Tesla();

            MyTesla.MainColor        = "Fire Engine Red";
            MyTesla.MaximumOccupancy = "2";
            MyTesla.BatteryKWh       = 8;

            Ram MyRam = new Ram();

            MyRam.MainColor        = "Canary Yellow";
            MyRam.MaximumOccupancy = "4";
            MyRam.FuelLevel        = 3;


            Console.WriteLine("And they're off!");
            Console.WriteLine("---------------------------");
            MyVehicle.Drive();
            MyVehicle.Turn("right");
            MyVehicle.Stop();
            Console.WriteLine("---------------------------");
            MyTesla.Drive();
            MyTesla.Turn("left");
            MyTesla.Stop();
            Console.WriteLine("---------------------------");
            MyRam.Drive();
            MyRam.Turn("right, then left");
            MyRam.Stop();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Zero MidnightBlue = new Zero()
            {
                BatteryKWh       = 15.5,
                MainColor        = "MidnightBlue",
                MaximumOccupancy = "2 people"
            };

            MidnightBlue.Drive();
            MidnightBlue.Turn();
            MidnightBlue.Stop();
            Console.WriteLine();

            Tesla Burgandy = new Tesla()
            {
                BatteryKWh       = 24.5,
                MainColor        = "Burgandy",
                MaximumOccupancy = "5 people"
            };

            Burgandy.Drive();
            Burgandy.Turn();
            Burgandy.Stop();
            Console.WriteLine();

            Ram Silver = new Ram()
            {
                FuelCapacity     = 32.5,
                MainColor        = "Silver",
                MaximumOccupancy = "5 people"
            };

            Silver.Drive();
            Silver.Turn();
            Silver.Stop();
            Console.WriteLine();

            Cessna White = new Cessna()
            {
                FuelCapacity     = 123.2,
                MainColor        = "White",
                MaximumOccupancy = "32 people"
            };

            White.Drive();
            White.Turn();
            White.Stop();
            Console.WriteLine();
        }