Пример #1
0
        static void Main(string[] args)
        {
            Zero  fxs    = new Zero();
            Zero  fx     = new Zero();
            Tesla modelS = new Tesla();
            Tesla model3 = new Tesla();
            Tesla modelX = new Tesla();
            Tesla modelY = new Tesla();

            //Add electric vehicles to the list
            List <IElectricPowered> electricVehicles = new List <IElectricPowered> {
                fx, fxs, modelS, model3, modelX, modelY
            };

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

            //Add gas vehicles to list
            List <IGasPowered> gasVehicles = new List <IGasPowered> {
                ram, cessna150
            };

            //Refuel gas vehicles
            gasVehicles.ForEach(gv => gv.RefuelTank());
        }
Пример #2
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");
            foreach (IElectricVehicle ev in electricVehicles)
            {
                Console.WriteLine($"{ev.CurrentChargePercentage}");
            }

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

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

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

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

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

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

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

            foreach (IGasPoweredVehicle gv in gasVehicles)
            {
                Console.WriteLine($"{gv.CurrentTankPercentage}");
            }
        }
Пример #3
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();
        }
Пример #4
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Clear();
            Zero fxs = new Zero()
            {
                MainColor  = "Electric blue",
                SaddleBags = 2,
                CurrentChargePercentage = 7
            };
            Zero fx = new Zero()
            {
                MainColor  = "Vespa blue",
                SaddleBags = 0,
                CurrentChargePercentage = 12
            };
            Tesla modelS = new Tesla()
            {
                MainColor = "Slate Grey",
                Doors     = 4,
                CurrentChargePercentage = 22
            };
            Cessna mx410 = new Cessna()
            {
                MainColor             = "White",
                FuelCapacity          = 150.0,
                StartingTankLevel     = 19.0,
                CurrentTankPercentage = "1/8",
                Wings = "mostly intact"
            };

            Ram definitelyNotAnF150 = new Ram()
            {
                MainColor             = "Yellow",
                FuelCapacity          = 35.0,
                StartingTankLevel     = 3.0,
                CurrentTankPercentage = "1/8",
                AddOns = "gun rack"
            };

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

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

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

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

            // fxs.Drive ();
            // fxs.Turn ();
            // fxs.Stop ();
            // modelS.Drive ();
            // modelS.Turn ();
            // modelS.Stop ();
            // mx410.Drive ();
            // mx410.Turn ();
            // mx410.Stop ();
            // definitelyNotAnF150.Drive ();
            // definitelyNotAnF150.Turn ();
            // definitelyNotAnF150.Stop ();

            List <IGasolineVehicles> gasVehicles = new List <IGasolineVehicles> ()
            {
                definitelyNotAnF150,
                mx410
            };

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

            foreach (IGasolineVehicles gv in gasVehicles)
            {
                // This should completely refuel the gas tank
                gv.RefuelTank();
            }
            Console.Clear();
            foreach (IElectricVehicle ev in electricVehicles)
            {
                string   type      = ev.GetType().ToString();
                string[] splitType = type.Split('.');
                string   message   =
                    $"{ev.MainColor} {splitType[1]} batteries charged to {ev.CurrentChargePercentage}%";
                MooseSays(message);
            }

            foreach (IGasolineVehicles gv in gasVehicles)
            {
                string   type      = gv.GetType().ToString();
                string[] splitType = type.Split('.');
                string   message   = $"{gv.MainColor} {splitType[1]} fuel tank {gv.CurrentTankPercentage}";
                MooseSays(message);
            }
        }