Esempio n. 1
0
 /// <summary>
 /// Methos changes the chosen vehicle state
 /// </summary>
 /// <param name="i_licenseNumber">the change is made by the given license number</param>
 /// <param name="i_vehicleState">current vehicle change</param>
 public void ChangeVehicleState(string i_licenseNumber, e_VehicleState i_vehicleState)
 {
     if (CheckIfDictionaryNotEmpty() == true)
     {
         if (m_ownerVehicleDictionary.TryGetValue(i_licenseNumber, out m_ownerDetailsAndVehicle) == true)
         {
             m_ownerDetailsAndVehicle = m_ownerVehicleDictionary[i_licenseNumber];
             m_ownerDetailsAndVehicle.VehicleState = i_vehicleState;
             if (m_ownerVehicleDictionary.Remove(i_licenseNumber) == true)
             {
                 m_ownerVehicleDictionary.Add(i_licenseNumber, m_ownerDetailsAndVehicle);
             }
             else
             {
                 throw new Exception();
             }
         }
         else
         {
             throw new FormatException();
         }
     }
     else
     {
         throw new Exception("Vehicle Does not exsist in this garage\n");
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Method adds the current chosen vehicle state to a list of strings that holds the license number
        /// </summary>
        /// <param name="i_listOfDetailedStructs"> list of structs, each holding owner & vehicle details</param>
        /// <param name="i_vehicleState">get the current vehicle state</param>
        /// <returns>returns the list of license numbers as individual string</returns>
        public static List <string> MakeSpecificTypeOfListByStatus(List <OwnerAndVehicleDetails> i_listOfDetailedStructs, e_VehicleState i_vehicleState)
        {
            List <string> listOfLicenseNumbers = new List <string>();

            foreach (OwnerAndVehicleDetails individualStructInList in i_listOfDetailedStructs)
            {
                if (individualStructInList.VehicleState == i_vehicleState)
                {
                    listOfLicenseNumbers.Add(individualStructInList.OwnerVehicle.LicenseNumber);
                }
            }

            return(listOfLicenseNumbers);
        }