Exemplo n.º 1
0
        /// <summary>
        /// Unpark car
        /// </summary>
        public static void RemoveVehicle()
        {
            bool   regNumOK = false;
            string registrationNum;

            do
            {
                ui.PrintLine("Input the registration number of the vehicle");
                registrationNum = ui.GetInput().ToUpper();

                if (!garageHandler.ValidateRegNum(registrationNum))
                {
                    PrintIncorrectInputWarning("The registration number is invalid. Please try again!");
                }
                else if (garageHandler.IsCreated())
                {
                    PrintIncorrectInputWarning("No garage exists. Create a garage first");
                }
                else
                {
                    regNumOK = true;

                    if (garageHandler.UnparkVehicle(registrationNum))
                    {
                        ui.PrintLine($"\nThe vehicle with registration number {registrationNum} has been removed from the garage\nPress enter to continue!");
                        ui.GetInput();
                    }
                    else
                    {
                        PrintIncorrectInputWarning("No vehicle with registration number {registrationNum} was found in the garage");
                    }
                }
            } while (!regNumOK);
        }