コード例 #1
0
        private void refuelVehicle(string i_LicenseNumber)
        {
            try
            {
                Messages.ClearAndDisplayMessage(Messages.SelectFuelType);
                Console.WriteLine(EnumOperations.ListEnumValues <eFuelType>(k_EnumListWithNumbers));
                eFuelType fuelChoice = (eFuelType)getOptionFromUser(r_NumOfFuelTypes);
                Messages.ClearAndDisplayMessage(Messages.EnterFuelAmount);
                float fuelToAdd;

                while (!float.TryParse(Console.ReadLine(), out fuelToAdd))
                {
                    Console.WriteLine(Messages.InvalidNumberInserted);
                }

                r_GarageManager.RefuelVehicle(i_LicenseNumber, fuelChoice, fuelToAdd);
                Messages.ClearAndDisplayMessage(Messages.RefueledSuccessfully);
            }
            catch (Exception e)
            {
                Messages.ClearAndDisplayMessage(e.Message);
            }

            enterToContinue();
        }
コード例 #2
0
        private void changeVehicleStatus()
        {
            string  licenseNumber = insertLicenseNumber();
            Vehicle vehicle;

            if (r_GarageManager.FindVehicle(licenseNumber, out vehicle))
            {
                bool v_InvalidInput = true;

                Messages.ClearAndDisplayMessage(Messages.SelectVehicleStatus);
                Console.WriteLine(EnumOperations.ListEnumValues <eVehicleStatus>(k_EnumListWithNumbers));
                while (v_InvalidInput)
                {
                    int newStatus = getOptionFromUser(r_NumOfVehicleStatuses);

                    try
                    {
                        r_GarageManager.ChangeVehicleStatus(licenseNumber, (eVehicleStatus)newStatus);
                        Messages.ClearAndDisplayMessage(Messages.StatusHasBeenChanged);
                        break;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }
            else
            {
                Messages.ClearAndDisplayMessage(Messages.VehicleIsNotInGarage);
            }

            enterToContinue();
        }
コード例 #3
0
        private void displayListOfVehiclesInGarage()
        {
            Messages.ClearAndDisplayMessage(Messages.SelectListType);
            int    option = getOptionFromUser(k_TwoOptions);
            string listOfVehiclesToDisplay = string.Empty;

            switch (option)
            {
            case 1:
                listOfVehiclesToDisplay = r_GarageManager.DisplayAllVehicles();
                break;

            case 2:
                Messages.ClearAndDisplayMessage(Messages.SelectSpecificList);
                Console.WriteLine(EnumOperations.ListEnumValues <eVehicleStatus>(k_EnumListWithNumbers));
                eVehicleStatus statusOfVehiclesToShow = (eVehicleStatus)getOptionFromUser(r_NumOfVehicleStatuses);
                listOfVehiclesToDisplay = r_GarageManager.DisplayVehiclesByStatus(statusOfVehiclesToShow);
                break;
            }

            if (listOfVehiclesToDisplay == string.Empty)
            {
                listOfVehiclesToDisplay = Messages.EmptyList;
            }

            printAndEnterToContinue(listOfVehiclesToDisplay);
        }
コード例 #4
0
        private eVehicleType getVehicleTypeFromUser()
        {
            Messages.ClearAndDisplayMessage(Messages.ChooseVehicleType);
            Console.WriteLine(EnumOperations.ListEnumValues <eVehicleType>(k_EnumListWithNumbers));
            int          numOfVehicleTypes = Enum.GetNames(typeof(eVehicleType)).Length;
            int          vehicleTypeChosen = getOptionFromUser(numOfVehicleTypes);
            eVehicleType vehicleType       = (eVehicleType)vehicleTypeChosen;

            return(vehicleType);
        }
コード例 #5
0
        private void initMenu()
        {
            string allEnumVehicleType = EnumOperations.ListEnumValues <eVehicleType>(true);

            m_ArrOfAllEnumVehicleType = allEnumVehicleType.Split('\n');
            foreach (string newItem in m_ArrOfAllEnumVehicleType)
            {
                vehicleTypeComboBox.Items.Add(newItem.Replace("\r", string.Empty));
            }
        }