Пример #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=====");

            // Iterates through all electric vehicles
            // Show each vehicle's initial charge
            // Recharge the vehicle
            // Show the new charge
            foreach (IElectricVehicle ev in electricVehicles)
            {
                ev.DisplayCharge();
                ev.ChargeBattery();
                ev.DisplayCharge();
                Console.WriteLine();
            }
            /***********************************************/

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

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

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

            // Iterates through all gas vehicles
            // Show each vehicle's initial gas tank amount
            // Refuel the vehicle
            // Show the new gas tank
            foreach (IGasVehicle gv in gasVehicles)
            {
                gv.DisplayGasTank();
                gv.RefuelTank();
                gv.DisplayGasTank();
                Console.WriteLine();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            //Cessna
            Cessna newPlane = new Cessna();

            newPlane.FuelCapacity     = 200.50;
            newPlane.MainColor        = "green";
            newPlane.MaximumOccupancy = "4";
            //methods
            newPlane.Drive(newPlane);
            newPlane.Turn("east");
            newPlane.Stop("airport");

            //Zero
            Zero newMoto = new Zero();

            newMoto.BatteryKwh       = 5000;
            newMoto.MainColor        = "matte black";
            newMoto.MaximumOccupancy = "6";
            //methods
            newMoto.Drive(newMoto);
            newMoto.Turn("west");
            newMoto.Stop("grocery store");

            //Tesla
            Tesla modelS = new Tesla();

            modelS.BatteryKWh       = 10000;
            modelS.MainColor        = "blue";
            modelS.MaximumOccupancy = "20";
            modelS.Drive(modelS);
            modelS.Turn("north");
            modelS.Stop("aquarium");

            //Ram
            Ram rebel = new Ram();

            rebel.FuelCapacity     = 20.10;
            rebel.MainColor        = "black";
            rebel.MaximumOccupancy = "100";
            //methods
            rebel.Drive(rebel);
            rebel.Turn("south");
            rebel.Stop("park");
        }
Пример #3
0
        static void Main(string[] args)
        {
            // Build a collection of all vehicles that fly


            List <IAir> AirVehicleList = new List <IAir>();

            Cessna Cessna172 = new Cessna()
            {
                Wheels            = 3,
                Doors             = 3,
                PassengerCapacity = 5,
                Winged            = true,
                TransmissionType  = "None",
                EngineVolume      = 31.1,
                MaxAirSpeed       = 309.0
            };

            Boeing Boeing747 = new Boeing()
            {
                Wheels            = 12,
                Doors             = 8,
                PassengerCapacity = 420,
                Winged            = true,
                TransmissionType  = "None",
                EngineVolume      = 102.3,
                MaxAirSpeed       = 575.0
            };

            AirVehicleList.Add(Cessna172);
            AirVehicleList.Add(Boeing747);

            // With a single `foreach`, have each vehicle Fly()\

            foreach (var plane in AirVehicleList)
            {
                plane.Fly();
            }

            // Build a collection of all vehicles that operate on roads

            Car FerrariSpider = new Car()
            {
                PassengerCapacity = 3,
                Winged            = false,
                TransmissionType  = "Manual",
                EngineVolume      = 1.6,
                Wheels            = 4,
                Doors             = 2,
                MaxLandSpeed      = 210
            };

            Motorcycle Ducati916 = new Motorcycle()
            {
                PassengerCapacity = 2,
                Winged            = false,
                TransmissionType  = "Manual",
                EngineVolume      = 1.3,
                Wheels            = 2,
                Doors             = 0,
                MaxLandSpeed      = 160.4
            };

            List <IGround> GroundVehicleList = new List <IGround>();

            GroundVehicleList.Add(FerrariSpider);
            GroundVehicleList.Add(Ducati916);

            foreach (var vehicle in GroundVehicleList)
            {
                vehicle.Drive();
            }



            // With a single `foreach`, have each road vehicle Drive()

            // Build a collection of all vehicles that operate on water

            List <IAir> WaterVehicleList = new List <IAir>();

            // With a single `foreach`, have each water vehicle Drive()
        }