public static bool readDate(out DateTime dept) { string day, month, year; Console.WriteLine("enter day : "); day = Console.ReadLine(); Console.WriteLine("enter month : "); month = Console.ReadLine(); Console.WriteLine("enter year : "); year = Console.ReadLine(); if (SystemHandler.checkDate(day, month, year)) { dept = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day)); return(true); } dept = new DateTime(); return(false); }
public void interact() { while (true) { Console.WriteLine(PassengerList); string choice = Console.ReadLine(); switch (choice) { case "1": bool yes = false; string origin, dest, travelClass, flightType; DateTime dept = new DateTime(); DateTime ret = new DateTime(); string day, month, year; FlightType p1 = FlightType.OneWay; FlightSeatClass p2 = FlightSeatClass.Economy; Console.WriteLine("Please, enter the origin city : "); origin = Console.ReadLine(); Console.WriteLine("Please, enter the destination city : "); dest = Console.ReadLine(); Console.WriteLine("Please, enter the travel class : \n" + "(1 : First class) (2 : Economy class) (3 : Buinsness class)"); travelClass = Console.ReadLine(); if (!(SystemHandler.checkInt(travelClass) && int.Parse(travelClass) >= 1 && int.Parse(travelClass) <= 3)) { goto label; } Console.WriteLine("Please, enter the flight type : \n" + "(1 : one way) (2 : return)"); flightType = Console.ReadLine(); Console.WriteLine("Please, enter the departur date : "); Console.WriteLine("day : "); day = Console.ReadLine(); Console.WriteLine("month : "); month = Console.ReadLine(); Console.WriteLine("year : "); year = Console.ReadLine(); if (SystemHandler.checkDate(day, month, year)) { dept = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day)); } else { goto label; } if (flightType == "2") { Console.WriteLine("Please, enter the return date : "); Console.WriteLine("day : "); day = Console.ReadLine(); Console.WriteLine("month : "); month = Console.ReadLine(); Console.WriteLine("year : "); year = Console.ReadLine(); if (SystemHandler.checkDate(day, month, year)) { ret = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day)); if (ret <= dept) { goto label; } } else { goto label; } } if (flightType == "1") { p1 = FlightType.OneWay; } else if (flightType == "2") { p1 = FlightType.Return; } else { goto label; } if (travelClass == "1") { p2 = FlightSeatClass.First; } else if (travelClass == "2") { p2 = FlightSeatClass.Economy; } else if (travelClass == "3") { p2 = FlightSeatClass.Buisness; } else { goto label; } if (SystemHandler.viewMatchedFlight(origin, dest, p2, p1, dept, ret)) { yes = true; } label: if (yes) { Console.WriteLine("Please, enter the number of the flight you want to book in : "); string number = Console.ReadLine(); if (!passenger.MakeFlightBooking(int.Parse(number), p2)) { Console.WriteLine("wrong choice for flight number or you don't have enough money to book"); } } break; case "2": passenger.ViewPassengerBookings(); Console.WriteLine("Please, choose the teckit code you want to cancel"); string code = Console.ReadLine(); if (!passenger.CancelFlightBooking(code)) { Console.WriteLine("No teckit with such a code"); } break; case "3": passenger.ViewPassengerBookings(); break; case "4": FileHandler.Add(ObjectChoices.Passenger, passenger); return; default: break; } } }