コード例 #1
0
 /// <summary>
 /// Helper method to park a vehicle to its desired type
 /// </summary>
 /// <param name="manager">Parking lot manager</param>
 /// <param name="type">Parking type</param>
 private static void ParkVehicle(IParkingLotManager manager, ParkingType type)
 {
     try
     {
         // Print the booking number if vehicle is parked successfully
         Console.WriteLine(string.Format("Ticket number: {0}", manager.ParkVehicle(type)));
     }
     catch (ParkingSpaceNotAvailableException ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #2
0
        /// <summary>
        /// Unparks a vehicle
        /// </summary>
        /// <param name="manager">Parking lot manager</param>
        private static void UnparkVehicle(IParkingLotManager manager)
        {
            Console.WriteLine("Please enter ticket number of vehicle to be unparked");
            var ticketNumber = Console.ReadLine();

            try
            {
                manager.UnParkVehicle(ticketNumber);
                Console.WriteLine(string.Format("{0} is un parked successfully and is ready for exit!", ticketNumber));
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }