Ejemplo n.º 1
0
 /// <summary>
 ///     sets the car status in garage to Enums.eStatusInGarage.InRepair
 /// </summary>
 /// <param name="i_OwnerName"></param>
 /// <param name="i_OwnerPhone"></param>
 /// <param name="i_VehicleType"></param>
 /// <param name="i_EnergySourceType"></param>
 /// <param name="i_CurrentEnergyAmount"></param>
 /// <param name="i_VehicleModelName"></param>
 /// <param name="i_WheelsManufacturerName"></param>
 /// <param name="i_LicensePlate"></param>
 /// <param name="i_CurrentAirPressure"></param>
 /// <param name="i_SpecificVehicleParams">
 ///     used in case of extra params thats relevant to specific vehicle type (see
 ///     example)
 /// </param>
 /// <example>
 ///     GarageManager garageManager = new GarageManager();
 ///     string owner = "Yossi";
 ///     string phoneNumber = "050-1234567";
 ///     VehicleCreation.eVehicleType vehicleType =VehicleCreation.eVehicleType.Car;
 ///     VehicleCreation.eEnergySourceType energySourceType = VehicleCreation.eEnergySourceType.Fuel;
 ///     float currentEnergyAmount = 40.0f;
 ///     string vehicleModelName = "KIA";
 ///     string wheelsManufacturerName = "Michelin";
 ///     string licensePlate = "12-345-67";
 ///     float currentAirPressure = 20.0f;
 ///     object[] specificCarParams  = new object[2];
 ///     specificCarParams[(int)VehicleCreation.eCarSpecificParams.CarColor] = Enums.eCarColor.Red;
 ///     specificCarParams[(int)VehicleCreation.eCarSpecificParams.NumberOfDoors] = Enums.eNumberOfDoors.Four;
 ///     garageManager.EnterVehicleToGarage(owner,phoneNumber, vehicleType, energySourceType, currentEnergyAmount,
 ///     vehicleModelName, wheelsManufacturerName, licensePlate, currentAirPressure, specificCarParams);
 /// </example>
 public void EnterVehicleToGarage(string i_OwnerName, string i_OwnerPhone,
                                  VehicleCreation.eVehicleType i_VehicleType,
                                  VehicleCreation.eEnergySourceType i_EnergySourceType,
                                  float i_CurrentEnergyAmount, string i_VehicleModelName, string i_WheelsManufacturerName,
                                  string i_LicensePlate, float i_CurrentAirPressure,
                                  params object[] i_SpecificVehicleParams)
 {
     if (!r_VehiclesDictionaryByLicensePlate.ContainsKey(i_LicensePlate))
     {
         //new vehicle
         VehicleInGarageInfo newVehicleInGarageInfo = new VehicleInGarageInfo(i_OwnerName, i_OwnerPhone,
                                                                              Enums.eStatusInGarage.InRepair);
         Vehicle newVehicle = VehicleCreation.CreateNewVehicle(i_VehicleType,
                                                               i_EnergySourceType, i_CurrentEnergyAmount, i_VehicleModelName, i_WheelsManufacturerName,
                                                               i_LicensePlate, i_CurrentAirPressure,
                                                               i_SpecificVehicleParams);
         r_VehiclesDictionaryByLicensePlate.Add(i_LicensePlate, newVehicle);
         r_VehiclesInGarageInfo.Add(newVehicle, newVehicleInGarageInfo);
     }
     else
     {
         //existing vehicle
         r_VehiclesInGarageInfo[r_VehiclesDictionaryByLicensePlate[i_LicensePlate]].StatusInGarage =
             Enums.eStatusInGarage.InRepair;
     }
 }
Ejemplo n.º 2
0
        private void enterNewVehicleToGarage()
        {
            try
            {
                string messageToUser, ownerName, phoneNumber, vehicleModelName, wheelsManufacturerName, licensePlate;
                float  currentEnergyAmount, currentAirPressure;

                messageToUser = "******";
                ownerName     = getSimpleStringFromUser(messageToUser);

                messageToUser = "******";
                phoneNumber   = getOwnerPhoneNumber(messageToUser);

                messageToUser = "******";
                VehicleCreation.eVehicleType vehicleType =
                    getEnumValueFromUserByType <VehicleCreation.eVehicleType>(messageToUser);

                messageToUser = "******";
                VehicleCreation.eEnergySourceType energySourceType =
                    getEnumValueFromUserByType <VehicleCreation.eEnergySourceType>(messageToUser);

                messageToUser       = string.Format("Enter {0} current energy amount:", energySourceType);
                currentEnergyAmount = getFloatUserInput(messageToUser);

                messageToUser    = "******";
                vehicleModelName = getSimpleStringFromUser(messageToUser);

                messageToUser          = "******";
                wheelsManufacturerName = getSimpleStringFromUser(messageToUser);

                messageToUser = "******";
                licensePlate  = getVehicleLicensePlate(messageToUser);

                messageToUser      = "******";
                currentAirPressure = getFloatUserInput(messageToUser);

                object[] specificVehicleParams = getSpecificVehicleParams(vehicleType);

                r_GarageManager.EnterVehicleToGarage(ownerName, phoneNumber, vehicleType, energySourceType,
                                                     currentEnergyAmount, vehicleModelName, wheelsManufacturerName, licensePlate, currentAirPressure,
                                                     specificVehicleParams);

                writeSuccessMessage(string.Format("New {0} entered with license plate: {1}!", vehicleType, licensePlate));
            }
            catch (Exception i_Exception)
            {
                writeErrorMessage(i_Exception.Message);
            }
        }