Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Forma 1 simple factory");
            MotorFactory motorFactoryMethod = new MotorFactory();
            var          diselMethod        = motorFactoryMethod.CreateInstance(TypeMotor.Disel);

            Console.WriteLine(diselMethod.InyectarCombustible(20));
            var gasolinaMethod = motorFactoryMethod.CreateInstance(TypeMotor.Gasolina);

            Console.WriteLine(gasolinaMethod.InyectarCombustible(10));
            Console.ReadKey();

            Console.WriteLine("Forma 2 Factory Method");
            IMotorFactory motorFactory = ObtenerMotor(TypeMotor.Gasolina);

            IMotor gasolina = motorFactory.CreateInstance();

            Console.WriteLine(gasolina.InyectarCombustible(50));

            IMotor disel = ObtenerMotor(TypeMotor.Disel).CreateInstance();

            Console.WriteLine(disel.InyectarCombustible(540));

            Console.ReadKey();
        }
Exemplo n.º 2
0
 public ForwardMotor(IMotorFactory motorFactory)
 {
     this.motorFactory = motorFactory;
 }
Exemplo n.º 3
0
        public Rover(IMotorFactory motorFactory)
        {
            this.motorFactory = motorFactory;

            CurrentLocation = new Location(0, 0, 0);
        }