Пример #1
0
        public static void Main()
        {
            VehicleInitialDetails setup = CreateNewSetup();

            GarageManager gm     = new GarageManager();
            bool          exists = gm.CheckIfVehicleExists("12221C");

            gm.AddNewVehicle(setup);
            exists = gm.CheckIfVehicleExists("12221C");
            gm.ChangeVehicleRepairState("12221C", eRepairState.Fixed);
            gm.FillTyrePressure("12221C");
            gm.RefuelVehicle("12221C", Fuel.eFuelType.Octan98, 30f);
        }
Пример #2
0
        private static void printAddNewVehicleScreen()
        {
            List <object> listOfDetailsForVehicle = new List <object>();

            Console.Clear();
            Console.WriteLine(
                // $G$ DSN-001 (-20) The UI must not know specific types and their properties concretely! It means that when adding a new type you'll have to change the code here too!
                string.Format(
                    @"Please choose vehicle type (Choose a number between 1-5): 
1. Fuel Bike
2. Electric Bike
3. Fuel Car
4. Electric Car
5. Truck"));
            int          lowestPossibleUserChoice  = 1;
            int          highestPossibleUserChoice = Enum.GetNames(typeof(eVehicleType)).Length;
            int          vehicleType     = manageUserInput(lowestPossibleUserChoice, highestPossibleUserChoice);
            eVehicleType vehicleTypeEnum = (eVehicleType)vehicleType;

            try
            {
                listOfDetailsForVehicle = setDetailsAccordingToVehicleType(listOfDetailsForVehicle, vehicleTypeEnum);
                s_GarageManager.AddNewVehicle(vehicleTypeEnum, listOfDetailsForVehicle);
                Console.Clear();
                Console.WriteLine(
                    string.Format(
                        @"Vehicle Added successfully to the system!
Press Enter to return to the Main Menu"));
                Console.ReadLine();
            }
            catch (ArgumentException ex)
            {
                if (ex.Message.Equals("Different Type of Car"))
                {
                    Console.WriteLine(
                        string.Format(
                            @"The Vehicle already exists in the garage, but is registered with a Different Vehicle Type! 
Press Enter to return to the main menu..."));
                    Console.ReadLine();
                }

                if (ex.Message.Equals("License Exists in Garage"))
                {
                    Console.WriteLine(
                        string.Format(
                            @"The Vehicle already exists in the garage!
Press Enter to return to the main menu..."));
                    Console.ReadLine();
                }
            }
        }
Пример #3
0
        private void addNewVehicleUI()
        {
            VehicleProperties.eStateOfService statusOfNewVehicle;
            Dictionary <string, object>       basicArgumentsMap = new Dictionary <string, object>();
            string plateNumber = getStringFromUser(Strings.enter_plate_number);

            try
            {
                VehicleProperties vehicle = m_Garage.GetVehicleByPlateNumber(plateNumber);
                printMessage(string.Format(Strings.change_status_options, VehicleProperties.s_StateListOptions[(int)vehicle.Status]));
                showOptions(VehicleProperties.s_StateListOptions);
                statusOfNewVehicle = (VehicleProperties.eStateOfService)getUserChoice(1, VehicleProperties.s_StateListOptions.Count) - 1;
                vehicle.Status     = statusOfNewVehicle;
            }
            catch (Exception i_PlateError)
            {
                if (i_PlateError is KeyNotFoundException)
                {
                    showError(string.Format(Strings.plate_didnt_found, plateNumber));
                }
                else
                {
                    showError(Strings.unknown_error);
                }

                printMessage(Strings.create_new_vehicle);
                VehicleManager.eVehicleTypes vehicleType = getOptionFromUser <VehicleManager.eVehicleTypes>(Strings.choose_type_of_vehicle, VehicleManager.VehicleList, -1);
                basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyTypeOfVehicle, vehicleType);
                basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyOwnerName, getStringFromUser(Strings.enter_owner_name));
                basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyPhoneNumber, getStringFromUser(Strings.enter_phone_number));
                basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyModelName, getStringFromUser(Strings.enter_model_name));
                basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyWheelManufacturer, getStringFromUser(Strings.enter_wheel_manufacturer));
                basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyPlateNumber, plateNumber);
                basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyRepairStatus, getOptionFromUser <VehicleProperties.eStateOfService>(Strings.choose_status_of_vehicle, VehicleProperties.s_StateListOptions, -1));
                basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyCurrentEnergyLevel, getFloatFromUser(Strings.enter_current_energy_level));
                basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyCurrentWheelPressure, getFloatFromUser(Strings.enter_current_wheel_pressure_level));
                getMoreInformationBasedOnType(VehicleManager.s_OptionsToAskUserByTypes[vehicleType], ref basicArgumentsMap);
                m_Garage.AddNewVehicle(VehicleManager.CreateNewVehicle(ref basicArgumentsMap), ref basicArgumentsMap);
            }
        }