Пример #1
0
        static void Main(string[] args)
        {
            AirlineCompany airlineCompany = new AirlineCompany();

            airlineCompany[3] = new Flight(4, "Helsinki", "Tokyo", "11.11.2019", 900);

            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine(airlineCompany[i].toString());
            }

            Console.Write("Enter a flight's ID: ");
            int id = Convert.ToInt16(Console.ReadLine());

            Console.WriteLine("Flight found: ");

            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine(airlineCompany[i].FindFlight(id));
            }

            Console.Write("Enter a price: ");
            int price = Convert.ToInt16(Console.ReadLine());

            ProcessFlightDelegate pfd  = new ProcessFlightDelegate(airlineCompany.DisplayFlight);
            ProcessFlightDelegate pfd2 = new ProcessFlightDelegate(airlineCompany.DisplayFlightshort);
            ProcessFlightDelegate pfd3 = pfd + pfd2;

            Console.WriteLine(airlineCompany.ProcessCheapPrice(pfd3, price));

            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            AirlineCompany airlineCompany = new AirlineCompany();

            airlineCompany[3] = new Flight(1229, "Seoul", "Jakarta", "20.05.2019", 792);

            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine(airlineCompany[i].toString());
            }

            Console.Write("Please enter a flight ID: ");
            int input = Convert.ToInt16(Console.ReadLine());

            Console.WriteLine("Found Result: ");
            for (int k = 0; k < 4; k++)
            {
                Console.WriteLine(airlineCompany[k].FindFlight(input));
            }
            Console.WriteLine("Please enter your budget: ");
            int price = Convert.ToInt16(Console.ReadLine());

            ProcessFlightDelegate pfd  = new ProcessFlightDelegate(airlineCompany.ShowFlight);
            ProcessFlightDelegate pfd2 = new ProcessFlightDelegate(airlineCompany.ShowFlightshort);
            ProcessFlightDelegate pfd3 = pfd + pfd2;

            Console.WriteLine(airlineCompany.ProcessCheapPrice(pfd3, price));

            Console.ReadLine();
        }
        public String ProcessCheapPrice(ProcessFlightDelegate processFlightDelegate, int price)
        {
            String info = "";

            foreach (Flight flight in flights)
            {
                if (flight.CheckPrice(price))
                {
                    info += processFlightDelegate(flight) + "\n";
                }
            }
            return(info);
        }