コード例 #1
0
        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
 public Green(IColourDecoration decorations)
 {
     this.decorations = decorations;
 }
コード例 #3
0
 public Black(IColourDecoration decorations)
 {
     this.decorations = decorations;
 }
コード例 #4
0
 public Silver(IColourDecoration decorations)
 {
     this.decorations = decorations;
 }
コード例 #5
0
 public White(IColourDecoration decorations)
 {
     this.decorations = decorations;
 }