コード例 #1
0
        public void addVehicleToRepository(IAddVehicleForm form)
        {
            VehicleType type = VehicleType.other; //default
            Vehicle newVehicle;
            switch (form.getVehicleType())
            {
                case "Car":
                    type = VehicleType.car;
                    break;
                case "Minivan":
                    type = VehicleType.minivan;
                    break;
                case "Caravan":
                    type = VehicleType.caravan;
                    break;
                case "Other":
                    type = VehicleType.other;
                    break;
            }

            if(form.getAddress() == "")
            {
                newVehicle = VehicleFactory.CreateVehicleWithNoInfoAdress(type,form.getVehicleModel(),form.getCapacity(), form.getConsumption(), new City(form.getCity(), form.getCountry()));

            }
            else
            {
                 newVehicle = VehicleFactory.CreateVehicleWithInfoAdress(type,form.getVehicleModel(),form.getCapacity(), form.getConsumption(), new City(form.getCity(), form.getCountry()),form.getAddress());

            }
            VehicleRepository.GetInstance().AddNewVehicle(newVehicle);
            form.closeForm();
        }
コード例 #2
0
 public void closeAddVehicleForm(IAddVehicleForm form)
 {
     form.closeForm();
 }