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();
        }
예제 #2
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();
        }
예제 #3
0
 public Truck(ICarColour carColour, IWheel wheel, Brand brand, Numberplate numberplate, EngineClass engine)
     :
     base(carColour, wheel, brand, numberplate, engine)
 {
 }