Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Zero  fxs    = new Zero();
            Zero  fx     = new Zero();
            Tesla modelS = new Tesla();

            List <IElectricVehicles> electricVehicles = new List <IElectricVehicles>()
            {
                fx, fxs, modelS
            };

            Console.WriteLine("Electric Vehicles");
            foreach (IElectricVehicles ev in electricVehicles)
            {
                Console.WriteLine($"{ev.CurrentChargePercentage}%");
            }

            foreach (IElectricVehicles ev in electricVehicles)
            {
                // This should charge the vehicle to 100%
                ev.ChargeBattery();
            }

            foreach (IElectricVehicles ev in electricVehicles)
            {
                Console.WriteLine($"{ev.CurrentChargePercentage}%");
            }

            /***********************************************/

            Ram    ram       = new Ram();
            Cessna cessna150 = new Cessna();

            List <IGasVehicles> gasVehicles = new List <IGasVehicles>()
            {
                ram, cessna150
            };

            Console.WriteLine("Gas Vehicles");
            foreach (IGasVehicles gv in gasVehicles)
            {
                Console.WriteLine($"{gv.CurrentTankPercentage}%");
            }

            foreach (IGasVehicles gv in gasVehicles)
            {
                // This should completely refuel the gas tank
                gv.RefuelTank();
            }

            foreach (IGasVehicles gv in gasVehicles)
            {
                Console.WriteLine($"{gv.CurrentTankPercentage}%");
            }
        }
Exemplo n.º 2
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("--------------------");
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Zero  fxs    = new Zero();
            Zero  fx     = new Zero();
            Tesla modelS = new Tesla();

            List <IElectricVehicle> electricVehicles = new List <IElectricVehicle>()
            {
                fx, fxs, modelS
            };

            Console.WriteLine("Electric Vehicles");

            electricVehicles.ForEach(v => Console.WriteLine($"{v.BatteryKWh}"));

            electricVehicles.ForEach(v => v.ChargeBattery());

            electricVehicles.ForEach(v => Console.WriteLine($"{v.BatteryKWh}"));



            Ram    ram       = new Ram();
            Cessna cessna150 = new Cessna();

            List <IGasVehicle> gasVehicles = new List <IGasVehicle>()
            {
                ram, cessna150
            };

            Console.WriteLine("");
            Console.WriteLine("Gas Vehicles");

            gasVehicles.ForEach(v => Console.WriteLine(v.FuelCapacity));

            gasVehicles.ForEach(v => v.RefuelTank());

            gasVehicles.ForEach(v => Console.WriteLine(v.FuelCapacity));
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            // instantiate each vehicle
            Zero myZero = new Zero()
            {
                MainColor = "smoke"
            };
            Cessna myCessna = new Cessna()
            {
                MainColor = "silver"
            };
            Tesla myTesla = new Tesla()
            {
                MainColor = "black"
            };
            Ram myRam = new Ram()
            {
                MainColor = "red"
            };

            List <IElectricVehicle> electricVehicles = new List <IElectricVehicle>()
            {
                myZero, myTesla
            };

            Console.WriteLine("Electric Vehicles");
            foreach (IElectricVehicle ev in electricVehicles)
            {
                Console.WriteLine($"{ev.BatteryKWh}");
            }

            foreach (IElectricVehicle ev in electricVehicles)
            {
                // This should charge the vehicle to 100%
                ev.ChargeBattery();
            }

            foreach (IElectricVehicle ev in electricVehicles)
            {
                Console.WriteLine($"{ev.BatteryKWh}");
            }

            /***********************************************/

            List <IGasVehicle> gasVehicles = new List <IGasVehicle>()
            {
                myRam, myCessna
            };

            Console.WriteLine("Gas Vehicles");
            foreach (IGasVehicle gv in gasVehicles)
            {
                Console.WriteLine($"{gv.FuelCapacity}");
            }

            foreach (IGasVehicle gv in gasVehicles)
            {
                // This should completely refuel the gas tank
                gv.RefuelTank();
            }

            foreach (IGasVehicle gv in gasVehicles)
            {
                Console.WriteLine($"{gv.FuelCapacity}");
            }

            // myCessna.Drive();
            // myCessna.Turn("right");
            // myCessna.Stop();
            // Console.WriteLine("");


            // myTesla.Drive();
            // myTesla.Turn("left");
            // myTesla.Stop();
            // Console.WriteLine("");


            // myRam.Drive();
            // myRam.Turn("right");
            // myRam.Stop();
            // Console.WriteLine("");


            // myZero.Drive();
            // myZero.Turn("left");
            // myZero.Stop();
            // Console.WriteLine("");
        }
Exemplo n.º 7
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}%");
            }
        }