示例#1
0
        /// <summary>
        /// Runners this instance.
        /// </summary>
        public void Runner()
        {
            ////creating object of concrete using the reference of an interface
            VehicleFactory factory = new ConcreteVehicleFactory();
            ////calling method using the reference of an interface
            IFactory scooter = factory.GetVehicle("Scooter");

            scooter.Drive(10);
            ////calling method using reference of an interface
            IFactory bike = factory.GetVehicle("Bike");

            bike.Drive(20);
        }
示例#2
0
        static void Main(string[] args)
        {
            VehicleFactory factory = new ConcreteVehicleFactory();

            IVehicle scooter = factory.GetVehicle("Scooter");

            scooter.Drive(10);

            IVehicle bike = factory.GetVehicle("Bike");

            bike.Drive(20);

            Console.ReadKey();
        }
示例#3
0
        private static void FactoryPattern()
        {
            VehicleFactory factory = new ConcreteVehicleFactory();

            IFactory scooter = factory.GetVehicle("Scooter");

            scooter.Drive(10);

            IFactory bike = factory.GetVehicle("Bike");

            bike.Drive(20);

            Console.ReadKey();
        }