Exemplo n.º 1
0
        private void showFullVehicleInfoMenu()
        {
            try
            {
                string  regNum  = getExistingRegistrationNumberFromUser();
                Vehicle vehicle = m_Garage.GetVehicleByRegNum(regNum);
                Dictionary <string, string> vehicleInfo = m_Garage.GetVehicleInfo(ref vehicle);

                foreach (KeyValuePair <string, string> pair in vehicleInfo)
                {
                    Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
                }

                Console.WriteLine(string.Empty);
            }
            catch (ArgumentException i_ArgumentException)
            {
                if (i_ArgumentException.Message == "Vehicle_Not_Exist")
                {
                    Console.WriteLine("There is no vehicle in the garage with the entered registration number.");
                }
            }
            catch (Exception i_Ex)
            {
                if (i_Ex.Message == "Invalid data input")
                {
                    Console.WriteLine("Error: {0}.{1}", i_Ex.Message, Environment.NewLine);
                }
                else
                {
                    Console.WriteLine("Error: Unknown.{0}", Environment.NewLine);
                }
            }
        }
Exemplo n.º 2
0
        public static void DisplayVehicle(Garage i_Garage)
        {
            Console.WriteLine(Messages.sr_EnterLicenseNumber);
            string licenseNumber = Utils.GetValidStringFromUser();

            try
            {
                Console.WriteLine(i_Garage.GetVehicleInfo(licenseNumber));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }