public void ControlGarage() { do { PrintingUtils.PrintingOpening(); string option = Console.ReadLine(); bool isValid = Enum.TryParse(option, out eOption result) && Enum.IsDefined(typeof(eOption), result); if (isValid) { try { controlGarageOptions(result); } catch { PrintingUtils.Delay(); } } else { Console.WriteLine("Please choose from the options above!"); System.Threading.Thread.Sleep(3000); } }while (m_LeaveStore == false); Console.WriteLine("Goodbye!"); }
private void controlGarageOptions(eOption i_Option) { try { AutoRepairShop.VehicleInShop.eVehicleStatus?status; string licenseNumber; Console.Clear(); switch (i_Option) { case eOption.AddVehicle: addVehicle(); break; case eOption.ShowVehiclesByLicense: PrintingUtils.PrintLicensesList(r_AutoRepairShop.ShowAllVehiclesInGarage()); break; case eOption.ShowVehiclesByStatus: status = getStatus(); PrintingUtils.PrintLicensesList(r_AutoRepairShop.ShowAllVehiclesInGarage(status), status); break; case eOption.ModifyStatus: licenseNumber = getLicenseNumber(); if (r_AutoRepairShop.IsVehicleExist(licenseNumber)) { status = getStatus(); r_AutoRepairShop.SetNewStatusToVehicle(licenseNumber, status, out bool isSucceeded); PrintingUtils.StatusModified(licenseNumber, status, isSucceeded); } else { throw new ArgumentException("Vehicle is not exist in the garage"); } break; case eOption.InflateWheels: licenseNumber = getLicenseNumber(); r_AutoRepairShop.SetWheelsPressureToMaximum(licenseNumber, out bool isInflated); PrintingUtils.InflateWheels(licenseNumber, isInflated); break; case eOption.RefuelVehicle: licenseNumber = getLicenseNumber(); if (r_AutoRepairShop.IsVehicleExist(licenseNumber)) { getFuelToAdd(out FuelVehicle.eFuelType fuelType, out float fuelToAdd); r_AutoRepairShop.FillInEnergyToVehicle( licenseNumber, fuelToAdd, out bool isRefueled, fuelType); PrintingUtils.EnergyAdded(licenseNumber, isRefueled, fuelType); } else { throw new ArgumentException("Vehicle is not exist in the garage"); } break; case eOption.LoadVehicle: licenseNumber = getLicenseNumber(); if (r_AutoRepairShop.IsVehicleExist(licenseNumber)) { float minutesToAdd = getMinutesToLoad(); r_AutoRepairShop.FillInEnergyToVehicle(licenseNumber, minutesToAdd, out bool isLoaded); PrintingUtils.EnergyAdded(licenseNumber, isLoaded); } else { throw new ArgumentException("Vehicle is not exist in the garage"); } break; case eOption.ShowVehicleDetails: licenseNumber = getLicenseNumber(); PrintingUtils.PrintVehicleDetails( r_AutoRepairShop.ShowDetailsOfVehicle(licenseNumber, out bool isExist), isExist); break; case eOption.Exit: m_LeaveStore = true; break; default: throw new ValueOutOfRangeException(1, 9); } if (i_Option != eOption.Exit) { PrintingUtils.Delay(); } } catch (Exception ex) { PrintingUtils.PrintExceptionErrors(ex); throw; } }