public void Execute()
        {
            SelectCarType();
            Brand brand = SelectBrand();

            SelectColour();
            IColourDecoration colourDecoration = SelectColourDeco();
            EngineClass       engine           = SelectEngine();

            SelectWheel();
            IWheelDeco  wheelDeco   = SelectWheelDeco();
            Numberplate numberplate = AssignNumberplate();


            IWheel wheel = (IWheel)Activator.CreateInstance(wheelList[listOfIndex.Last()], wheelDeco);

            listOfIndex.RemoveAt(listOfIndex.Count - 1);
            ICarColour carColour = (ICarColour)Activator.CreateInstance(carColourList[listOfIndex.Last()], colourDecoration);

            listOfIndex.RemoveAt(listOfIndex.Count - 1);

            Vehicle vehicle = (Vehicle)Activator.CreateInstance(types[listOfIndex.Last()], new object[] { carColour, wheel, brand, numberplate, engine });

            Console.WriteLine("Congratulation you successfully added a new vehicle");

            carDealer.AddVehicleToList(vehicle);
            command = new PrintVehicleCommand()
            {
                List = carDealer.Vehicles
            };
            command.Execute();
            listOfIndex.Clear();
        }
        private Numberplate AssignNumberplate()
        {
            Console.WriteLine("Please enter your Numberplate: ");

            input = Console.ReadLine();

            Numberplate numberplate = new Numberplate(input);

            return(numberplate);
        }
Ejemplo n.º 3
0
        protected Vehicle(ICarColour carColour, IWheel wheel, Brand brand, Numberplate numberplate, EngineClass engine)
        {
            this.brand       = brand;
            this.carColour   = carColour;
            this.numberplate = numberplate;
            this.wheel       = wheel;
            this.engine      = engine;

            id    = ++counter;
            price = wheel.Price() + carColour.CalculatePrice() + brand.GetPrice() + engine.GetPrice();
        }
Ejemplo n.º 4
0
 public Truck(ICarColour carColour, IWheel wheel, Brand brand, Numberplate numberplate, EngineClass engine)
     :
     base(carColour, wheel, brand, numberplate, engine)
 {
 }
Ejemplo n.º 5
0
 public Vehicle CreateVehicle(CarColour carColour, IWheel wheel, Brand brand, Numberplate numberplate, EngineClass engine)
 {
     return(new Car(carColour, wheel, brand, numberplate, engine));
 }
Ejemplo n.º 6
0
        public Vehicle CreateVWVehicle(string name, CarColour carColour, IWheel wheel, Numberplate numberplate, EngineClass engine)
        {
            this.brand = new VW(name);

            return(new Car(carColour, wheel, brand, numberplate, engine));
        }