// Builds requested vehicle if we haven't already
        public void BuildVehicle(string make)
        {
            ICar car = null;

            // If we already have that vehicle don't create another
            if (cars.ContainsKey(make))
            {
                Console.WriteLine("You can only have one of each type of car.");
                return;
            }

            // Create all new vehicles
            if (make.Equals("Honda", StringComparison.OrdinalIgnoreCase))
            {
                car = new Honda(make);
                cars.Add(make, car);
                return;
            }
            if (make.Equals("Toyota", StringComparison.OrdinalIgnoreCase))
            {
                car = new Toyota(make);
                cars.Add(make, car);
                return;
            }
            if (make.Equals("Subaru", StringComparison.OrdinalIgnoreCase))
            {
                car = new Subaru(make);
                cars.Add(make, car);
                return;
            }

            // If this factory doesn't make the requested vehicle let the user know
            Console.WriteLine($"This factory does not make {make} vehicles.");
            return;
        }
Exemple #2
0
        public override Car GetCar()
        {
            Toyota TCar = new Toyota
            {
                model = "",
                speed = 0
            };

            Console.WriteLine("Car Company: " + TCar.company);
            Console.WriteLine("Model: " + TCar.model);
            Console.WriteLine("Top Speed: " + TCar.speed);
            return(TCar);
        }