Exemple #1
0
        private void changeVehicleStateOp()
        {
            string           requestedLicenseNumber;
            string           input;
            eVehicleStatuses status;

            getValidLicenseNumber(out requestedLicenseNumber);
            Console.Clear();
            try
            {
                Console.WriteLine("Please choose the status you would like to set:");
                MenusPrinter.PrintVehicleStatuses();
                input  = Console.ReadLine();
                status = CustomConverter.ConvertStringToVehicleStatus(input);
                m_GarageManager.ChangeVehicleStatus(requestedLicenseNumber, status);
                Console.WriteLine("Successfuly changed status for vehicle with license number:{0}", requestedLicenseNumber);
            }
            catch (FormatException e)
            {
                Console.WriteLine(string.Format("Error has occured!{0}{1}", Environment.NewLine, e.Message));
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(string.Format("Error has occured!{0}{1}", Environment.NewLine, e.Message));
            }
            catch (ValueOutOfRangeException e)
            {
                Console.WriteLine(string.Format("Error has occured!{0}{1}", Environment.NewLine, e.Message));
            }
        }
Exemple #2
0
        private void goToChoice(int i_Choice)
        {
            Console.Clear();
            switch (i_Choice)
            {
            case ((int)eMenuOptions.InsertNewCar):
                m_GarageManager.InsertNewCar();
                break;

            case ((int)eMenuOptions.ShowAllDrivingLicenses):
                m_GarageManager.ShowAllLicenseNumbers();
                break;

            case ((int)eMenuOptions.ChangeVehicleStatus):
                m_GarageManager.ChangeVehicleStatus();
                break;

            case ((int)eMenuOptions.AddPressureToMax):
                m_GarageManager.FillPressureToMax();
                break;

            case ((int)eMenuOptions.AddFuel):
                m_GarageManager.AddFuel();
                break;

            case ((int)eMenuOptions.Charge):
                m_GarageManager.ChargeVehicle();
                break;

            case ((int)eMenuOptions.ShowFullVehicleDetails):
                m_GarageManager.ShowFullVehicleDetails();
                break;
            }
        }
Exemple #3
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();
        }
Exemple #4
0
        private void changeVehicleStatus(string i_LicenseNumber)
        {
            MenuScreen statusScreen = r_Screens[eUIScreens.VehicleStatuses] as MenuScreen;

            statusScreen.Display(out string userInput);

            eVehicleStatus changeStatusTo = (eVehicleStatus)parseMenuOption(userInput);

            r_GarageManager.ChangeVehicleStatus(i_LicenseNumber, changeStatusTo);
        }
        private static void changeVehicleStatusScreen()
        {
            Console.Clear();
            Console.WriteLine("Please Enter Vehicle License Number that you want to change: ");
            bool   isNumber = false;
            string license  = string.Empty;

            while (!isNumber)
            {
                try
                {
                    license  = verifyStringContainsOnlyNumbers(k_LengthOfLicenseNumber);
                    isNumber = true;
                }
                catch (FormatException fm)
                {
                    Console.WriteLine("Not a valid Number! Try Again:");
                    continue;
                }
            }

            if (checkIfLicenseDoesntExist(license))
            {
                Console.WriteLine(
                    string.Format(
                        @"Vehicle you wanted to change status for doesnt exist is the system. 
Press Enter to go back to Main Menu..."));
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine(
                    string.Format(
                        @"Please Enter the new status of the vehicle: 
1. In Progress
2. Fixed
3. Payed"));
                int            lowestPossibleUserChoice  = 1;
                int            highestPossibleUserChoice = Enum.GetNames(typeof(eVehicleStatus)).Length - 1;
                int            displayOption             = manageUserInput(lowestPossibleUserChoice, highestPossibleUserChoice);
                eVehicleStatus status = (eVehicleStatus)displayOption;
                s_GarageManager.ChangeVehicleStatus(license, status);
                Console.WriteLine(
                    string.Format(
                        @"
Vehicle Status has been Changed!
Press Enter to return to the Main Menu"));
                Console.ReadLine();
            }
        }
Exemple #6
0
        private bool changeVehicleStatus()
        {
            bool   isVehicleExists = false;
            string licenseNumber   = getLicenseNumber();

            isVehicleExists = r_GarageManager.IsVehicleExists(licenseNumber);
            if (isVehicleExists == true)
            {
                string[] vehicleStatuses = Enum.GetNames(typeof(OwnerInfo.eVehicleSatuses));
                Console.WriteLine("Select new status:");
                for (int i = 1; i <= vehicleStatuses.Length; i++)
                {
                    Console.WriteLine("{0}. {1}", i, vehicleStatuses[i - 1]);
                }

                bool isValidSelection = false;
                while (isValidSelection == false)
                {
                    int newStatus = readIntFromConsole();
                    try
                    {
                        r_GarageManager.ChangeVehicleStatus(licenseNumber, (OwnerInfo.eVehicleSatuses)newStatus);
                        isValidSelection = true;
                    }
                    catch (ArgumentException)
                    {
                        UIMessages.DisplayMessages(UIMessages.eGeneralMessages.InvalidSelection);
                    }
                }
            }
            else
            {
                Console.WriteLine("Vehicle does not exist in the garage.");
            }

            return(isVehicleExists);
        }
        private void enterAnOrderToGarageFromMainManu()
        {
            bool inputIsOk = true;

            do
            {
                try
                {
                    inputIsOk = true;
                    Console.WriteLine("Please enter licence number:");
                    string licenceOfVehicleToAdd = Console.ReadLine();
                    if (licenceOfVehicleToAdd.Length <= 0)
                    {
                        throw new FormatException("Input for licence number has not been received");
                    }

                    if (m_Garage.OrdersDictionary.ContainsKey(licenceOfVehicleToAdd))
                    {//vehicle already in garage
                        Console.WriteLine("Vehicle is already in the garage");
                        m_Garage.ChangeVehicleStatus(licenceOfVehicleToAdd, Order.eVehicleStatus.FixingUp);
                    }
                    else
                    {//vehicle is not in the garage
                        Order lastAddedOrder = enterOrderDetailsToGarage(licenceOfVehicleToAdd);
                        enterVehicleDetails(lastAddedOrder.TheVehicle);
                        Console.WriteLine("Your vehicle was entered to the garage successfully");
                    }
                }

                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                    inputIsOk = false;
                }
            }while (!inputIsOk);
        }
Exemple #8
0
        private static void changeVehicleStatus(string i_LicencePlate)
        {
            if (s_MyGarage.CheckIfVehicleInGarage(i_LicencePlate) == s_MyGarage.VehicleNotInGarage)
            {
                notRegisteredVehiclesMessages();
            }
            else
            {
                s_MyGarage.ChangeVehicleStatus(i_LicencePlate, (eVehicleStatus)displayEnumOptions(typeof(eVehicleStatus), MessagesEnglish.k_GetNewStatusMessage));
                Console.WriteLine(MessagesEnglish.k_StatusChangedMessage + MessagesEnglish.k_GoingBackToMainMenuMessage);
                Thread.Sleep(1500);
            }

            Ex02.ConsoleUtils.Screen.Clear();
        }
Exemple #9
0
        private void changeVehicleStatus()
        {
            Console.WriteLine("Hello, please enter vehicle's License number in order to change the status:");
            string VehicleLicense = getNotEmptyInput();

            try
            {
                m_LogicManager.IsInGarage(VehicleLicense);
                Console.WriteLine(@"What this vehicle's new status?
(1) In Repair
(2) Repaired
(3) Payed");
                eCarStatus NewCarStatus = (eCarStatus)int.Parse(getNumberInRange(1, 3, true));
                m_LogicManager.ChangeVehicleStatus(VehicleLicense, NewCarStatus);
                Console.WriteLine("status of {0} changed to {1} status!", VehicleLicense, NewCarStatus);
                Console.ReadLine();
            }
            catch
            {
                Console.WriteLine("This vehicle License number not exsit in our garage, press enter for main menu");
                Console.ReadLine();
            }
        }
        // $G$ DSN-007 (-5) This method is too long, it should have been split into several methods.
        // $G$ DSN-011 (-7) The component responsible for creating vehicles should be implemented in the Logic project...
        private void insertVehicleFlow(string i_License)
        {
            bool            isVehicleInserted = false;
            int             selection         = getSelection(k_InsertVehicleTypeSelect, validCarTypeMenu);
            eValidVehicle   validVehicle      = (eValidVehicle)selection;
            ComposedVehicle vehicleToInsert   = null;

            if (GM.IsVehicleInGarage(i_License))
            {
                // print active car menu
                Console.WriteLine("The status of vehicle with the license {0} was changed to repair.", i_License);
                GM.ChangeVehicleStatus(i_License, eVehicleStatus.OnRepair);
            }
            else
            {
                // car not in garage - print "enter full details".
                DataExtractor dataExtractor = new DataExtractor(validVehicle, i_License);
                try
                {
                    if (validVehicle == eValidVehicle.ElectricalCar || validVehicle == eValidVehicle.RegCar)
                    {
                        vehicleToInsert = GM.CreateAutomobile(
                            dataExtractor.VehicleType,
                            dataExtractor.OwnerName,
                            dataExtractor.OwnerNumber,
                            dataExtractor.LicenseNumber,
                            dataExtractor.Model,
                            dataExtractor.WheelManufacturer,
                            dataExtractor.CurrentWheelPressure,
                            dataExtractor.PowerLeft,
                            dataExtractor.EColor,
                            dataExtractor.ENumOfDoors);
                    }
                    else if (validVehicle == eValidVehicle.RegMotorCycle ||
                             validVehicle == eValidVehicle.ElectricalCycle)
                    {
                        vehicleToInsert = GM.CreateMotorcycle(
                            dataExtractor.VehicleType,
                            dataExtractor.OwnerName,
                            dataExtractor.OwnerNumber,
                            dataExtractor.LicenseNumber,
                            dataExtractor.Model,
                            dataExtractor.WheelManufacturer,
                            dataExtractor.CurrentWheelPressure,
                            dataExtractor.PowerLeft,
                            dataExtractor.ELicenseType,
                            dataExtractor.EngineSize);
                    }
                    else
                    {
                        vehicleToInsert = GM.CreateTruck(
                            dataExtractor.VehicleType,
                            dataExtractor.OwnerName,
                            dataExtractor.OwnerNumber,
                            dataExtractor.LicenseNumber,
                            dataExtractor.Model,
                            dataExtractor.WheelManufacturer,
                            dataExtractor.CurrentWheelPressure,
                            dataExtractor.PowerLeft,
                            dataExtractor.TruckCapacity,
                            dataExtractor.IsCooled);
                    }

                    isVehicleInserted = GM.InsertVehicle(vehicleToInsert);

                    if (isVehicleInserted)
                    {
                        Console.WriteLine("Vehicle with license {0} has entered the garage.", i_License);
                        System.Threading.Thread.Sleep(1000);
                    }
                }
                catch (ValueOutOfRangeException voore)
                {
                    Console.WriteLine(voore.Message);
                    Console.WriteLine("Vehicle was not added");
                }
            }
        }