Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var fxs = new Zero();

            fxs.Name             = "Zero";
            fxs.MainColor        = "Black";
            fxs.MaximumOccupancy = 2;

            var modelS = new Tesla();

            modelS.Name             = "Tesla";
            modelS.MainColor        = "Red";
            modelS.MaximumOccupancy = 2;

            var mx410 = new Cessna();

            mx410.Name             = "Cessna";
            mx410.MainColor        = "White";
            mx410.MaximumOccupancy = 2;

            var pickup = new Ram();

            pickup.Name             = "Ram";
            pickup.MainColor        = "Orange";
            pickup.MaximumOccupancy = 2;

            fxs.Drive();
            fxs.Turn();
            fxs.Stop();

            Console.WriteLine("--------------------");

            modelS.Drive();
            modelS.Turn();
            modelS.Stop();

            Console.WriteLine("--------------------");

            mx410.Drive();
            mx410.Turn();
            mx410.Stop();

            Console.WriteLine("--------------------");

            pickup.Drive();
            pickup.Turn();
            pickup.Stop();

            Console.WriteLine("--------------------");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Tesla modelS = new Tesla()
            {
                BatteryKWh       = 300,
                MaximumOccupancy = 5,
                MainColor        = "silver"
            };

            Zero fsx = new Zero()
            {
                BatteryKWh       = 50,
                MaximumOccupancy = 1,
                MainColor        = "black"
            };
            Cessna s2100 = new Cessna()
            {
                FuelCapacity     = 100,
                MaximumOccupancy = 4,
                MainColor        = "white"
            };
            Ram srt = new Ram()
            {
                FuelCapacity     = 20,
                MaximumOccupancy = 4,
                MainColor        = "red"
            };

            modelS.Drive();
            modelS.Turn("Right");
            modelS.Stop();

            Console.WriteLine("");

            fsx.Drive();
            fsx.Turn("Left");
            fsx.Stop();

            Console.WriteLine("");

            s2100.Drive();
            s2100.Turn("Sharply Right");
            s2100.Stop();

            Console.WriteLine("");

            srt.Drive();
            srt.Turn("Slightly Left");
            srt.Stop();
        }
        static void Main(string[] args)
        {
            Zero fxs = new Zero();

            fxs.MainColor        = "white";
            fxs.MaximumOccupancy = "Two";

            Tesla modelS = new Tesla();

            modelS.MainColor        = "black";
            modelS.MaximumOccupancy = "four";

            Cessna mx410 = new Cessna();

            mx410.MainColor        = "pink";
            mx410.MaximumOccupancy = "fifty";

            Ram dodge = new Ram();

            dodge.MainColor        = "red";
            dodge.MaximumOccupancy = "four";

            fxs.Drive();
            fxs.Turn("right");
            fxs.Stop();

            Console.WriteLine("---------------");

            modelS.Drive();
            modelS.Turn("left");
            modelS.Stop();

            Console.WriteLine("---------------");

            mx410.Drive();
            mx410.Turn("up");
            mx410.Stop();

            Console.WriteLine("---------------");

            dodge.Drive();
            dodge.Turn("anywhere it wants to go");
            dodge.Stop();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Zero   fx             = new Zero();
            Cessna oneSevenTwo    = new Cessna();
            Tesla  modelS         = new Tesla();
            Ram    fifteenHundred = new Ram();

            fx.Drive();
            fx.Turn("sharp left turn to the express lane");
            fx.Stop();
            Console.WriteLine();
            oneSevenTwo.Drive();
            oneSevenTwo.Turn("nose dive into the pacific ocean");
            oneSevenTwo.Stop();
            Console.WriteLine();
            modelS.Drive();
            modelS.Turn("U turn into the wrong side of the road");
            modelS.Stop();
            Console.WriteLine();
            fifteenHundred.Drive();
            fifteenHundred.Turn("detour to the dirt road");
            fifteenHundred.Stop();
            Console.WriteLine();

            // List of electric vehicles
            List <IElectricVehicle> electricVehicles = new List <IElectricVehicle>()
            {
                fx,
                modelS
            };

            Console.WriteLine("Electric Vehicles");

            // Lists current battery level for each electric vehicle
            foreach (IElectricVehicle ev in electricVehicles)
            {
                Console.WriteLine($"Battery Level: {ev.CurrentChargePercentage}%");
            }

            // Invokes ChargeBattery() method on each electric vehicle
            foreach (IElectricVehicle ev in electricVehicles)
            {
                ev.ChargeBattery();
            }

            // Lists battery level for each electric vehicle after invoking ChargeBattery() method
            foreach (IElectricVehicle ev in electricVehicles)
            {
                Console.WriteLine($"New Battery Level: {ev.CurrentChargePercentage}%");
            }

            Console.WriteLine();

            // List of gas vehicles
            List <IGasVehicle> gasVehicles = new List <IGasVehicle>()
            {
                oneSevenTwo,
                fifteenHundred
            };

            Console.WriteLine("Gas Vehicles");

            // Lists current fuel level for each gas vehicle
            foreach (IGasVehicle gv in gasVehicles)
            {
                Console.WriteLine($"Current Fuel Level: {gv.CurrentTankPercentage}%");
            }

            // Invokes RefuelTank() method on each gas vehicle
            foreach (IGasVehicle gv in gasVehicles)
            {
                gv.RefuelTank();
            }

            // Lists fuel level for each gas vehicle after invoking RefuelTank() method
            foreach (IGasVehicle gv in gasVehicles)
            {
                Console.WriteLine($"New Fuel Level: {gv.CurrentTankPercentage}%");
            }
        }