static void Main(string[] args)
    {
        IFabricaVehiculo fabrica;

        Automovil[] autos = new Automovil[NoAutos];
        Console.WriteLine("Desea utilizar vehículos eléctricos (1) o de gasolina (2)");
        string seleccion = Console.ReadLine();

        if (seleccion == "1")
        {
            fabrica = new FabricaVehiculoElectricidad();
        }
        else
        {
            fabrica = new FabricaVehiculoGasolina();
        }

        for (int index = 0; index < NoAutos; index++)
        {
            autos[index] = fabrica.CreaAutomovil("Estándar", "Negro", 6 + index, 3.2);
        }

        foreach (Automovil auto in autos)
        {
            auto.MostrarCaracteristicas();
        }
    }
示例#2
0
            static void Main(string[] args)
            {
                FabricaVehiculo fabrica;

                Automovil[] autos    = new Automovil[nAutos];
                Scooter[]   scooters = new Scooter[nScooters];
                Console.WriteLine("Desea utilizar " +
                                  "vehículos eléctricos (1) o a gasolina (2):");
                string eleccion = Console.ReadLine();

                if (eleccion == "1")
                {
                    fabrica = new FabricaVehiculoElectricidad();
                }
                else
                {
                    fabrica = new FabricaVehiculoGasolina();
                }
                for (int index = 0; index < nAutos; index++)
                {
                    autos[index] = fabrica.creaAutomovil("estándar",
                                                         "amarillo", 6 + index, 3.2);
                }
                for (int index = 0; index < nScooters; index++)
                {
                    scooters[index] = fabrica.creaScooter("clásico",
                                                          "rojo", 2 + index);
                }
                foreach (Automovil auto in autos)
                {
                    auto.mostrarCaracteristicas();
                }
                foreach (Scooter scooter in scooters)
                {
                    scooter.mostrarCaracteristicas();
                }
            }
示例#3
0
 static void Main(string[] args)
 {
     FabricaVehiculo fabrica;
     Automovil[] autos = new Automovil[nAutos];
     Scooter[] scooters = new Scooter[nScooters];
     Console.WriteLine("Desea utilizar " +
       "vehículos eléctricos (1) o a gasolina (2):");
     string eleccion = Console.ReadLine();
     if (eleccion == "1")
     {
       fabrica = new FabricaVehiculoElectricidad();
     }
     else
     {
       fabrica = new FabricaVehiculoGasolina();
     }
     for (int index = 0; index < nAutos; index++)
       autos[index] = fabrica.creaAutomobile("estándar",
     "amarillo", 6+index, 3.2);
     for (int index = 0; index < nScooters; index++)
       scooters[index] = fabrica.creaScooter("clásico",
     "rojo", 2+index);
     foreach (Automovil auto in autos)
       auto.mostrarCaracteristicas();
     foreach (Scooter scooter in scooters)
       scooter.mostrarCaracteristicas();
 }