public GarageVehicle(string i_OwnerName, string i_OwnerPhoneNumber, Vehicle i_OwnerVehicle) { m_OwnerName = i_OwnerName; m_OwnerPhoneNumber = i_OwnerPhoneNumber; m_OwnerVehicle = i_OwnerVehicle; m_VehicleState = eVehicleState.InRepair; }
/// <summary> /// if i_State = 0 - no flag /// if i_State = 1 - flag of vehicles in repair /// if i_State = 2 - flag of vehicles that have been repaired /// if i_State = 3 - flag of vehicles that have been paid /// </summary> /// <param name="i_State"></param> /// <param name="i_Flag"></param> /// <returns></returns> public List <string> GetLicenseNumbers(int i_State) { List <string> retList = new List <string>(); // prints all list if (i_State == 0) { foreach (KeyValuePair <string, Vehicle> item in m_ListOfVehicle) { retList.Add(item.Key); } } else { // invalid input if (i_State < (int)eVehicleState.InRepair || i_State > (int)eVehicleState.Paid) { throw new ValueOutOfRangeException((int)eVehicleState.InRepair, (int)eVehicleState.Paid); } eVehicleState state = (eVehicleState)i_State; foreach (KeyValuePair <string, Customer> item in m_ListOfCustomers) { if (item.Value.VehicleState == state) { retList.Add(item.Key); } } } return(retList); }
public static string AsText(eVehicleState eState) { string enumDescripton = "null"; switch (eState) { case eVehicleState.Fix: { enumDescripton = "Fix"; break; } case eVehicleState.Fixed: { enumDescripton = "Fixed"; break; } case eVehicleState.Paid: { enumDescripton = "Paid"; break; } } return(enumDescripton); }
public bool IsValidVehicleState(string i_VehicleState, out eVehicleState o_VehicleState) { bool isValid = true; o_VehicleState = eVehicleState.InRepair; if (Enum.IsDefined(typeof(eVehicleState), i_VehicleState) == false) { int choiceNumeric; if (int.TryParse(i_VehicleState, out choiceNumeric) == false) { throw new FormatException("invalid state"); } else { if (isInStateTypeRange(choiceNumeric) == false) { throw new ValueOutOfRangeException(i_VehicleState, 1, 4); } } } Enum.TryParse(i_VehicleState, out o_VehicleState); return(isValid); }
/// <summary> /// return true value if the vehicle is in the garage, /// return false if not /// </summary> /// <param name="i_LicenseNumber"></param> /// <param name="i_State"></param> /// <returns></returns> public void ChangeVehicleState(string i_LicenseNumber, eVehicleState i_State) { Customer customer; m_ListOfCustomers.TryGetValue(i_LicenseNumber, out customer); customer.VehicleState = i_State; }
private void getDesiredNewState() { Console.Write("Please insert the requested state P, F or I: "); string desiredStatesStr = Console.ReadLine();; char state; try { if (!char.TryParse(desiredStatesStr, out state)) { throw new FormatException($"'{desiredStatesStr}' is not a valid input!"); } else if (state != 'I' && state != 'F' && state != 'P') { throw new ArgumentException($"'{desiredStatesStr}' is not a valid input!"); } m_DesiredNewVehicleState = (eVehicleState)Convert.ToInt32(state); if (!Enum.IsDefined(typeof(eVehicleState), m_DesiredNewVehicleState)) { throw new FormatException($"'{desiredStatesStr}' is not a valid input!"); } } catch (ArgumentException) { throw new FormatException($"'{desiredStatesStr}' is not a valid input!"); } m_IsInputValid = true; }
private bool isInStateTypeRange(int i_VehicleState) { eVehicleState lastFuelType = Enum.GetValues(typeof(eVehicleState)).Cast <eVehicleState>().Last(); eVehicleState firstFuelType = Enum.GetValues(typeof(eVehicleState)).Cast <eVehicleState>().First(); return(i_VehicleState >= (int)firstFuelType && i_VehicleState <= (int)lastFuelType); }
public List <CustomerCard> GetVehiclesByState(eVehicleState i_State) { List <CustomerCard> vehicles = new List <CustomerCard>(); if (r_ConnectedToDB == false) { foreach (KeyValuePair <string, CustomerCard> currentCostumer in r_CostumerBook) { if (i_State == eVehicleState.All) { vehicles.Add(currentCostumer.Value); } else { if (currentCostumer.Value.VehicleState == i_State) { vehicles.Add(currentCostumer.Value); } } } } else { vehicles = getVehiclesByStateFromDB(i_State); } return(vehicles); }
public Customer(string i_OwnerName, string i_OwnerPhoneNumber, Enums.eVehicleState i_State, Vehicle i_Vehical) { r_OwnerName = i_OwnerName; r_OwnerPhoneNumber = i_OwnerPhoneNumber; m_State = i_State; r_Vehicle = i_Vehical; }
public CustomerCard(Vehicle i_Vehicle, string i_Name, string i_Phone) { m_Vehicle = i_Vehicle; m_Name = i_Name; m_Phone = i_Phone; r_Id = i_Vehicle.LicesncePlate; m_VehicleState = eVehicleState.InRepair; }
/// <summary> /// asks the user for a license number and the new vehicle state he wants to change /// </summary> private void changeVehicleState() { string licenseNum = getExistingLicenseNumberFromUser(); eVehicleState state = (eVehicleState)getNewStateFromUser(); m_Garage.ChangeVehicleState(licenseNum, state); Console.WriteLine("The change has been done"); }
public void ChangeVehicleState(string i_LPN, eVehicleState i_NewState) { Vehicle vehicleToChangeTheState = m_VehicleGenerator.GetVehicleByLPN(i_LPN); if (vehicleToChangeTheState != null) { vehicleToChangeTheState.VehicleState = i_NewState; } }
public void ChangeCustomerVehicleState(CustomerCard i_Customer, eVehicleState i_VehicleState) { i_Customer.VehicleState = i_VehicleState; if (r_ConnectedToDB == true) { UpdateDefinition <BsonDocument> updateToDo = Builders <BsonDocument> .Update.Set("VehicleState", i_VehicleState.ToString()); UpdateCustomerInDB(i_Customer.Vehicle.LicesncePlate, updateToDo); } }
public VehicleAtGarage( string i_OwnerName, string i_OwnerCellphone, eVehicleState i_VehicleState, Vehicle i_Vehicle) { m_OwnerName = i_OwnerName; m_OwnerCellphone = i_OwnerCellphone; m_VehicleState = i_VehicleState; m_Vehicle = i_Vehicle; }
public void ChangeVehicleState(string i_LicenseNumber, eVehicleState i_NewState) { if (IsVehicleinGarage(i_LicenseNumber)) { m_Vehicles[i_LicenseNumber].VehicleState = i_NewState; } else { throw new ArgumentException("Couldn't find this license number."); } }
public void ChangeVehicleState(string i_LicenseNumber, eVehicleState i_State) { if (this.IsVehicleNumberExist(i_LicenseNumber)) { r_ListOfVehiclesGarageInfo[i_LicenseNumber].VehicleState = i_State; } else { throw new ArgumentException("Vehicle was not found in the garage"); } }
private void changeStateActions(eVehicleState i_VehicleState) { r_GarageManager.ChangeCustomerVehicleState(CustomerToTreat, i_VehicleState); StringBuilder message = new StringBuilder(); message.AppendLine($"{CustomerToTreat.Name}'s vehicle chagned state to: {CustomerToTreat.VehicleState}"); string title = "State changed"; MessageBox.Show(message.ToString(), title); this.Hide(); }
private void handleDisplayLicenseNumber() { if (!m_Garage.IsEmpty()) { eVehicleState sortState = UI.GetSortState(); UI.DisPlayLicenseNumbers(m_Garage.CreateLicenseNumbersListByState(sortState), sortState); } else { UI.PrintMessage(k_ErrGarageEmpty); } }
private static void filterVehiclesLicensePlates(List <VehicleAndOwnerDetails> i_VehicleAndOwnerDetails, eVehicleState[] i_VehicleStatesToFilter, List <string> i_FilteredLicensePlates) { foreach (VehicleAndOwnerDetails vehicleAndOwnerDetails in i_VehicleAndOwnerDetails) { eVehicleState vehicleState = vehicleAndOwnerDetails.OwnerVehicleState; if (Array.IndexOf(i_VehicleStatesToFilter, vehicleState) > -1) { i_FilteredLicensePlates.Add(vehicleAndOwnerDetails.Vehicle.LicenceNumber); } } }
public List <string> FilterVehiclesByState(eVehicleState i_VehicleState) { List <string> LicenseList = new List <string>(); foreach (KeyValuePair <string, VehicleAtGarage> vehicleAtGarage in m_Vehicles) { if (vehicleAtGarage.Value.VehicleState == i_VehicleState) { LicenseList.Add(vehicleAtGarage.Value.Vehicle.LicenseNumber); } } return(LicenseList); }
public List <string> GetAllVehicleLPNByState(eVehicleState i_State) { List <string> LPNList = new List <string>(); foreach (Vehicle vehicle in m_VehicleGenerator.VehicleList) { if (vehicle.VehicleState == i_State) { LPNList.Add(vehicle.LPN); } } return(LPNList); }
public void ChangeVehicleState(string i_LicenseNumber, eVehicleState i_NewState) { Customer requestedCustomer; bool vehicleExists = m_Customers.TryGetValue(i_LicenseNumber, out requestedCustomer); if (vehicleExists) { requestedCustomer.State = i_NewState; } else { throw new ArgumentException(k_GarageEmptyMsg); } }
// find and returns all license numbers which their matching car equals to the requested state public List <string> CreateLicenseNumbersListByState(eVehicleState i_SortState) { List <string> licenseNumbers = new List <string>(); foreach (KeyValuePair <string, Customer> customer in m_Customers) { if (i_SortState.Equals(eVehicleState.Undefined) || i_SortState.Equals(customer.Value.State)) { licenseNumbers.Add(customer.Key); } } return(licenseNumbers); }
private void showVehiclesActions(eVehicleState i_VehicleState) { List <CustomerCard> customers = r_GarageManager.GetVehiclesByState(i_VehicleState); if (customers.Count > 0) { FormShowVehicles formShowVehicles = new FormShowVehicles(customers, ComboBoxVehicleStates.Text); formShowVehicles.ShowDialog(); } else { string message = "There is no customers yet in the garage"; string title = "Garage Notification"; MessageBox.Show(message, title); } this.Hide(); }
// $G$ CSS-999 (-5) If you use string as a condition --> then you should have use constant here. internal static void DisPlayLicenseNumbers(List <string> i_SortedLicenseNumbersByState, eVehicleState i_SelectedState) { if (i_SortedLicenseNumbersByState.Count != k_Empty) { StringBuilder sorted = new StringBuilder(", sorted by the state '"); sorted.Append(i_SelectedState).Append("'"); Console.WriteLine("The license numbers of the vehicles in the garage{0} are:", i_SelectedState != eVehicleState.Undefined ? sorted.ToString() : ""); i_SortedLicenseNumbersByState.ForEach(Console.WriteLine); Console.Write(Environment.NewLine); } else { throw new ArgumentException(k_ErrFindSuitableVehicles); } }
public void ParseExsitcingVehicleInput(Dictionary <string, string> i_VehicleInput) { string tempStringBeforeParsing; float curEnergyLevel; string airPressures; if (!((i_VehicleInput.TryGetValue(sr_CurrentEnergyLevelKey, out tempStringBeforeParsing)) && (float.TryParse(tempStringBeforeParsing, out curEnergyLevel)))) { throw new FormatException("No Current Energy Level"); } if (!i_VehicleInput.TryGetValue(sr_WheelsAirPressureKey, out airPressures)) { throw new FormatException("No Wheels air pressure"); } this.m_CurrentEnergyLevel = curEnergyLevel; parseWheelAirPressure(airPressures); this.m_VehicleState = eVehicleState.RepairInProgress; }
private bool checkVehicleState(string i_VehicleState, out eVehicleState io_VehicleState) { bool isValid = true; io_VehicleState = eVehicleState.InRepair; if (String.IsNullOrEmpty(i_VehicleState) == true) { isValid = false; string message = "Vehicle state is empty"; string title = "Invalid Input"; MessageBox.Show(message, title); } else { try { isValid = r_GarageManager.IsValidVehicleState(i_VehicleState, out io_VehicleState); } catch (GarageLogic.ValueOutOfRangeException ec) { isValid = false; string message = ec.Message; string title = "Invalid Input"; MessageBox.Show(message, title); comboBoxVehicleStates.Text = string.Empty; } catch (FormatException ec) { isValid = false; string message = ec.Message; string title = "Invalid Input"; MessageBox.Show(message, title); comboBoxVehicleStates.SelectedIndex = -1; } } return(isValid); }
private void getDesiredStates() { string desiredStatesStr = Console.ReadLine(); string[] desiredStates = desiredStatesStr.Split(' '); char state; foreach (string stateStr in desiredStates) { try { if (!char.TryParse(stateStr, out state)) { throw new FormatException($"'{stateStr}' is not a valid input!"); } else if (state != 'I' && state != 'F' && state != 'P') { throw new ArgumentException($"'{stateStr}' is not a valid input!"); } eVehicleState vehicleState = (eVehicleState)Convert.ToInt32(state); if (!Enum.IsDefined(typeof(eVehicleState), vehicleState)) { throw new FormatException($"'{stateStr}' is not a valid input!"); } m_VehicleDesiredStates.Add(vehicleState); } catch (ArgumentException) { throw new FormatException($"'{stateStr}' is not a valid input!"); } } m_IsInputValid = true; }
private List <CustomerCard> getVehiclesByStateFromDB(eVehicleState i_State) { FilterDefinition <BsonDocument> DBFilter; List <CustomerCard> vehiclesByState = new List <CustomerCard>(); if (i_State == eVehicleState.All) { DBFilter = Builders <BsonDocument> .Filter.Empty; } else { DBFilter = Builders <BsonDocument> .Filter.Eq("VehicleState", i_State.ToString()); } List <BsonDocument> vehiclesByStateDocument = r_DBCollection.Find <BsonDocument>(DBFilter).ToList(); foreach (BsonDocument currVehicle in vehiclesByStateDocument) { vehiclesByState.Add(BsonSerializer.Deserialize <CustomerCard>(currVehicle)); } return(vehiclesByState); }
public List<string> GetVehicleLicenseNumbersByState(eVehicleState i_VehicleState) { List<string> vehicleList = new List<string>(); foreach (KeyValuePair<string, VehicleGarageInformation> vehicle in r_ListOfVehiclesGarageInfo) { if (vehicle.Value.VehicleState == i_VehicleState) { vehicleList.Add(vehicle.Key); } } return vehicleList; }
public static void ChangeVehicleState(string i_VehicleLicensePlate, eVehicleState i_NewState) { getVehicleDetailesByLicensePlate(i_VehicleLicensePlate).OwnerVehicleState = i_NewState; }
private static void updateVehicleAndOwnerDetails(Vehicle i_Vehicle, string i_OwnerName, string i_OwnerPhoneNumber, eVehicleState i_VehicleState) { VehicleAndOwnerDetails vehicleAndOwnerDetailsByLicensePlateToUpdate = m_GarageVehicles[i_Vehicle.LicenceNumber]; vehicleAndOwnerDetailsByLicensePlateToUpdate.OwnerVehicleState = i_VehicleState; vehicleAndOwnerDetailsByLicensePlateToUpdate.OwnerName = i_OwnerName; vehicleAndOwnerDetailsByLicensePlateToUpdate.OwnerPhoneNumber = i_OwnerPhoneNumber; }