private static IEnumerable <Passenger> AnyPassengers()
 {
     return(new List <Passenger>()
     {
         PassengerHelper.CreateGeneral("Steve", 30),
         PassengerHelper.CreateGeneral("Mark", 12),
         PassengerHelper.CreateGeneral("James", 36),
         PassengerHelper.CreateGeneral("Jane", 32),
         PassengerHelper.CreateLoyaltyMember("John", 29, 1000, true),
         PassengerHelper.CreateLoyaltyMember("Sarah", 45, 1250, false),
         PassengerHelper.CreateLoyaltyMember("Jack", 60, 50, false),
         PassengerHelper.CreateAirlineEmployee("Trevor", 47),
         PassengerHelper.CreateGeneral("Alan", 34),
         PassengerHelper.CreateGeneral("Suzy", 21),
         PassengerHelper.CreateDiscounted("Nik", 46)
     });
 }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                Setup();

                using (var file = new StreamReader(@"commands.txt"))
                {
                    var command = "";

                    do
                    {
                        command = file.ReadLine() ?? "";
                        var enteredText = command.ToLower();
                        if (enteredText.Contains("print summary"))
                        {
                            Console.WriteLine();
                            var summarySegments = enteredText.Split(' ');
                            if (summarySegments.Length > 2 && summarySegments[2] == "relaxed")
                            {
                                Console.WriteLine(_scheduledFlight.GetSummary(RuleSetType.Relaxed));
                            }
                            else
                            {
                                Console.WriteLine(_scheduledFlight.GetSummary(RuleSetType.Default));
                            }
                        }
                        else if (enteredText.Contains("add general"))
                        {
                            var passengerSegments = enteredText.Split(' ');
                            _scheduledFlight.AddPassenger(
                                PassengerHelper.CreateGeneral(
                                    passengerSegments[2],
                                    Convert.ToInt32(passengerSegments[3])));
                        }
                        else if (enteredText.Contains("add loyalty"))
                        {
                            var passengerSegments = enteredText.Split(' ');
                            _scheduledFlight.AddPassenger(
                                PassengerHelper.CreateLoyaltyMember(
                                    passengerSegments[2],
                                    Convert.ToInt32(passengerSegments[3]),
                                    Convert.ToInt32(passengerSegments[4]),
                                    Convert.ToBoolean(passengerSegments[5])));
                        }
                        else if (enteredText.Contains("add airline"))
                        {
                            var passengerSegments = enteredText.Split(' ');
                            _scheduledFlight.AddPassenger(
                                PassengerHelper.CreateAirlineEmployee(
                                    passengerSegments[2],
                                    Convert.ToInt32(passengerSegments[3])));
                        }
                        else if (enteredText.Contains("add discounted"))
                        {
                            var passengerSegments = enteredText.Split(' ');
                            _scheduledFlight.AddPassenger(
                                PassengerHelper.CreateDiscounted(
                                    passengerSegments[2],
                                    Convert.ToInt32(passengerSegments[3])));
                        }
                        else if (enteredText.Contains("exit"))
                        {
#if DEBUG
                            Console.ReadKey();
#endif
                            Environment.Exit(1);
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("UNKNOWN INPUT");
                            Console.ResetColor();
                        }
                    } while (command != "exit");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
#if DEBUG
                Console.ReadKey();
#endif
            }
        }