public static void ViewStatistics(DateTime strt, DateTime end) { double totalRevenu = 0; int scheduledFlight = 0; int totalBookings = 0; List <Object> all = FileHandler.GetAllObj(ObjectChoices.Flight); foreach (Object obj in all) { Flight now = (Flight)obj; if (now.DepartureDate <= end && now.DepartureDate >= strt) { if (now.FlightState == FlightSatus.Scheduled) { scheduledFlight++; } List <Eticket> list = now.getFlightBookings(); totalBookings += list.Count; foreach (Eticket et in list) { totalRevenu += et.FlightFare; } } } Console.WriteLine("Total Revenue = " + totalRevenu); Console.WriteLine("Total Bookings = " + totalBookings); Console.WriteLine("Number of flight scheduled = " + scheduledFlight); }
public static void ViewFlightBookings(int flightNumber, FlightSeatClass seat) { try { Flight flight = (Flight)FileHandler.Find(ObjectChoices.Flight, flightNumber.ToString()); List <Eticket> list = flight.getFlightBookings(seat); int counter = 0; foreach (Eticket et in list) { Console.WriteLine("Booking #" + (++counter) + " : "); Console.WriteLine(et); Console.WriteLine(); } if (counter == 0) { Console.WriteLine("no bookings"); } } catch (NullReferenceException e) { Console.WriteLine("Flight not Found"); } }