private void addVehicalToTheGarage() { bool doesVehicalExist = false; Console.Clear(); string licensePlate = askLicensePlate(); doesVehicalExist = r_Garage.DoesVehicalExist(licensePlate); if (doesVehicalExist) { r_Garage.ChangeVehicalStatus(licensePlate, GarageLogic.Enums.eVehicalStatus.InRepair); Console.WriteLine("The vehical license plate is already in the system, status changed to in repair."); } else { Console.Clear(); Console.WriteLine("Please choose the type of vehical you want to add"); VehicalFactory.eVehicalTypes vehicalType = (VehicalFactory.eVehicalTypes)enumParse <VehicalFactory.eVehicalTypes>(); VehicalInformation newVehical = new VehicalInformation(); Console.Clear(); string vehicalModel = askString("vehicals model"); newVehical.Vehical = VehicalFactory.CreateVehical(vehicalType, vehicalModel, licensePlate); askVehicalDetails(newVehical); r_Garage.AddVehical(newVehical); Console.WriteLine("The vehical was successfully added to the garage!"); } returnToMenuPrompt(); }
private void rechargeVehical() { Console.Clear(); try { VehicalInformation vehical = r_Garage.FindVehical(askLicensePlate()); if (vehical.Vehical.Engine is ElectricEngine) { Console.Write("Enter how much time do you wish to recharge for (hours): "); r_Garage.RechargeVehical(vehical, askUserForFloat()); Console.WriteLine("Vehical was successfully recharged!"); vehical.Vehical.UpdateEnergyPercentLeft(); } else { Console.WriteLine("Cannot recharge a vehical that does not run on electricity!"); } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } catch (ValueOutOfRangeException ex) { Console.WriteLine(ex.Message); } finally { returnToMenuPrompt(); } }
private void refuelVehical() { Console.Clear(); try { VehicalInformation vehical = r_Garage.FindVehical(askLicensePlate()); if (vehical.Vehical.Engine is GasEngine gasVehicalEngine) { Console.WriteLine("Select the desired fuel type to use: "); eFuelType fuelType = (eFuelType)enumParse <eFuelType>(); Console.WriteLine("Enter how much fuel do you wish to fill (liters): "); r_Garage.RefuelVehical(vehical, fuelType, askUserForFloat()); vehical.Vehical.UpdateEnergyPercentLeft(); Console.WriteLine("Vehical was successfully refueled!"); } else { Console.WriteLine("Cannot refuel a vehical that does not run on gas!"); } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } catch (ValueOutOfRangeException ex) { Console.WriteLine(ex.Message); } finally { returnToMenuPrompt(); } }
private void printVehicalInformation() { Console.Clear(); try { VehicalInformation vehical = r_Garage.FindVehical(askLicensePlate()); Console.WriteLine(vehical.ToString()); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } finally { returnToMenuPrompt(); } }
private void changeVehicalStatus() { Console.Clear(); try { VehicalInformation vehical = r_Garage.FindVehical(askLicensePlate()); Console.WriteLine("Please select your desired status:"); vehical.VehicalStatus = (eVehicalStatus)enumParse <eVehicalStatus>(); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } finally { returnToMenuPrompt(); } }
private void inflateWheels() { Console.Clear(); try { VehicalInformation vehical = r_Garage.FindVehical(askLicensePlate()); r_Garage.InflateWheels(vehical.Vehical.LicensePlate); Console.WriteLine("All the vehicals wheels were successfully inflated!"); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } finally { returnToMenuPrompt(); } }
private void askVehicalDetails(VehicalInformation i_Vehical) { getGeneralVehicalInformation(i_Vehical); if (i_Vehical.Vehical is Car) { askCarDetails(i_Vehical.Vehical); } if (i_Vehical.Vehical is Motorcycle) { askMotorcycleDetails(i_Vehical.Vehical); } if (i_Vehical.Vehical is Truck) { askTruckDetails(i_Vehical.Vehical); } updateEnergyPercentLeft(i_Vehical.Vehical); }