Beispiel #1
0
 public List<string> GetTicketInfo(Passenger[] passengers)
 {
     List<string> pInfo = new List<string>();
     pInfo.Add("Ticket: " + this.ToString());
     foreach (Passenger p in passengers)
     {
         foreach (Ticket t in p.tickets)
         {
             if (this.ticketID.Equals(t.ticketID))
             {
                 pInfo.Add("Passenger: " + p.ToString());
             }
         }
     }
     return pInfo;
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            Flight[] flights = new Flight[2]
            {
                new Flight(1000, "Honduras", "Siberia", new DateTime(2016, 6, 10)),
                new Flight(2000, "Siberia", "Honduras", new DateTime(2016, 7, 10))
            };

            Ticket[] tickets = new Ticket[2]
            {
                new Ticket(1234, 7777, flights[0], 1000),
                new Ticket(4321, 8888, flights[1], 2000)
            };

            Passenger[] passengers = new Passenger[2]
            {
                new EconomyPassenger(7777, "John", "Doe", "555-55-55", tickets, 25),
                new FirstClassPassenger(8888, "Jane", "Doe", "555-55-66", tickets, 25, "Vegan")
            };

            Array.ForEach(flights, x => Console.WriteLine("\nFlight: " + x.ToString()));
            Array.ForEach(tickets, x => Console.WriteLine("\nTicket: " + x.ToString()));
            Array.ForEach(passengers, x => Console.WriteLine("\nPassenger: " + x.ToString()));

            Console.WriteLine("\nFlight Class - SearchFlight method");
            Console.WriteLine(Flight.SearchFlight(flights, 1000));
            Console.WriteLine("\nTicket Class - GetPrice method");
            Console.WriteLine(tickets[0].GetPrice(tickets[0].ticketID));
            Console.WriteLine("\nTicket Class - GetTicketInfo method");
            List<string> pInfo = new List<string>();
            pInfo = tickets[0].GetTicketInfo(passengers);
            foreach (string s in pInfo)
            {
                Console.WriteLine(s);
            }
            Console.WriteLine("\nEconomyPassenger Class - GetInfo method");
            foreach (Passenger p in passengers)
            {
                Console.WriteLine(p.GetInfo(7777));
            }
            Console.WriteLine("\nFirstClassPassenger Class - GetInfo method");
            foreach (Passenger p in passengers)
            {
                Console.WriteLine(p.GetInfo(8888));
            }
            Console.WriteLine("\nPassenger Class - GetTicketInfo method");
            List<string> tInfo = new List<string>();
            tInfo = passengers[0].GetTicketInfo();
            foreach (string s in tInfo)
            {
                Console.WriteLine(s);
            }

            Console.WriteLine("\nPress enter to close...");
            Console.ReadLine();
        }