示例#1
0
        private void getNewFuelRateFromUser()
        {
            float fuelToAdd = 0;

            Screen.Clear();
            Console.WriteLine("Enter vehicle's license number:");
            string licenseNumberToAddFuel = Console.ReadLine();

            Fuel.eFuelType fuelType = getFuelTypeFromUser();
            Console.WriteLine("Please enter amount of fuel to add:");
            bool inputValid = float.TryParse(Console.ReadLine(), out fuelToAdd);

            if (inputValid == false)
            {
                throw new FormatException();
            }

            try
            {
                r_Garage.AddFuel(licenseNumberToAddFuel, fuelType, fuelToAdd);
                Screen.Clear();
                Console.WriteLine("{2} {0} Added successfully to Vehicle #{1} ", fuelType.ToString(), licenseNumberToAddFuel, fuelToAdd);
            }
            catch (MissingVehicleException ex)
            {
                Screen.Clear();
                Console.WriteLine("{0}", Environment.NewLine);
                Console.WriteLine("{0}", ex.Message);
                Console.WriteLine("{0}", Environment.NewLine);
            }
            catch (EngineTypeException ex)
            {
                Screen.Clear();
                Console.WriteLine("{0}", Environment.NewLine);
                Console.WriteLine("{0}", ex.Message);
                Console.WriteLine("{0}", Environment.NewLine);
            }
            catch (FuelTypeException ex)
            {
                Screen.Clear();
                Console.WriteLine("{0}", Environment.NewLine);
                Console.WriteLine("{0}", ex.Message);
                Console.WriteLine("{0}", Environment.NewLine);
            }
        }
示例#2
0
        public override List <string> GetVehicleFullDetailes()
        {
            List <string> vehicleDetailes = GetVehicleBaseDetailes();

            vehicleDetailes.Add("Number of doors: " + NumberOfDoors.ToString());
            vehicleDetailes.Add("Color: " + Color.ToString());
            if (m_PowerSource is Battery)
            {
                vehicleDetailes.Add("Power source type: Battery");
            }
            else if (m_PowerSource is Fuel)
            {
                vehicleDetailes.Add("Power source type: Fuel");
                vehicleDetailes.Add("Fuel type: " + k_CarFuelType.ToString());
            }

            return(vehicleDetailes);
        }