Example #1
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}");
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            Zero  fxs    = new Zero();
            Zero  fx     = new Zero();
            Tesla modelS = new Tesla();

            fxs.Drive();

            List <Zero> electricVehicles = new List <Zero>()
            {
                fxs, fxs
            };
        }
Example #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();
        }
        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);
            }
        }