示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine(Airline.NumberOfObjects);
            Airline Airline1  = new Airline();
            Airline Airline2  = new Airline(-1435, "MIAMI", "Boeing 767-232", "Tue");
            Airline Airline3  = new Airline(12498, "LEIPZIG", "Airbus A320-251N", "aaaaaaaaa");
            Airline Airline4  = new Airline("HONG KONG", 29589, "Boeing 737-8kn", new DateTime(2020, 10, 4, 00, 14, 00), "Fri");
            Airline Airline5  = new Airline("HANNOVER", -3841, "Airbus A320-251N", new DateTime(2020, 10, 2, 7, 34, 00), "Wed");
            Airline Airline6  = new Airline("TEL AVIV", 30491, "Boeing 737-8kn", new DateTime(2020, 10, 3, 15, 11, 00), "Thu");
            Airline Airline7  = new Airline("LONDON", 30491, "Boeing 737-8kn", new DateTime(2020, 10, 3, 15, 11, 00), "Thu");
            Airline Airline8  = new Airline("LYON", 83812, "Boeing 767-232", new DateTime(2020, 10, 5, 5, 20, 00), "Sat");
            Airline Airline9  = new Airline("CASABLANCA", 43589, "Boeing 737-8kn", new DateTime(2020, 10, 6, 20, 05, 00), "Sun");
            Airline Airline10 = new Airline("CASABLANCA", 4989, "Boeing 737-8kn", new DateTime(2020, 10, 6, 20, 05, 00), "Sun");
            Airline Airline11 = new Airline(flightnumber: 325, daysofweek: "Fri");
            Airline Airline12 = new Airline(23848, "CHICAGO", "Boeing 737-823");

            Airline[] AirlinesArray = new Airline[] { Airline1, Airline2, Airline3, Airline4, Airline5, Airline6, Airline7, Airline8, Airline9, Airline10, Airline11, Airline12 };

            Airline.FlightInfoByDestination(AirlinesArray, "LYON");
            Airline.FlightInfoByDayOfWeek(AirlinesArray, "Tue");

            Console.WriteLine("__________________________");
            Airline10.FlightInfo();
            //Airline10.DaysOfWeekGetSet = "Monday";
            Airline10.m_FlightNumber = 9999;
            Airline10.m_Destination  = 10;
            //Airline10.DestinationGetSet = "minsk";
            Airline10.FlightInfo();

            int flnumber = Airline7.m_FlightNumber;
            int number   = 9999999;

            Airline7.Parameters(ref flnumber, ref number, out int result);
            Console.WriteLine(result);

            Airline.ShowNumberOfObjects();
            Console.WriteLine(Airline9.Equals(Airline8));
            Console.WriteLine(Airline9.Equals(Airline10));
            Console.WriteLine(Airline4);
            Console.WriteLine(Airline11);
            Console.WriteLine(Airline6.GetType());


            var Anon = new { Destination = "TALLIN", FlightNumber = 1111, AircraftType = "Airbus A320-251N", DepartureTime = new DateTime(2020, 10, 6, 20, 05, 00), DaysOfWeek = "Monday" };

            Console.WriteLine($"Flight number: {Anon.FlightNumber}, to: {Anon.Destination}, aircraft type: {Anon.AircraftType}, departure time: {Anon.DepartureTime}, day: {Anon.DaysOfWeek}");
            //свойства анонимных типов доступны только для чтения; только в инициализаторе
        }
示例#2
0
        static void Main(string[] args)
        {
            var     anonType = new { destination = "Канто", departTime = "10:00" };
            Airline flight1  = new Airline(Airline.WeekDays.sunday);
            Airline flight2  = new Airline(2, Airline.WeekDays.friday, "Минск", "20:10");

            Console.WriteLine(flight2.ToString());
            Console.WriteLine(flight1.GetID());
            Airline.ClassInfo();
            Console.WriteLine(flight1.GetHashCode());
            Console.WriteLine("Новый пункт назначения");
            string newdest = Console.ReadLine();

            flight1.ChangeDestination(out flight1.destination, ref newdest);
            Console.WriteLine(flight1.destination);
            Console.WriteLine(flight1.Equals(flight2));
            Console.WriteLine(flight1.GetType());

            Airline[] flights = new Airline[5];
            for (int i = 0; i < 5; i++)
            {
                flights[i] = new Airline((Airline.WeekDays)i + 1);
            }

            Console.WriteLine();

            for (int i = 0; i < 5; i++)
            {
                if (flights[i].destination == "Минск")
                {
                    Console.WriteLine(flights[i].ToString());
                }
            }

            Console.WriteLine();

            for (int i = 0; i < 5; i++)
            {
                if (flights[i].Day == (Airline.WeekDays) 3)
                {
                    Console.WriteLine($"{flights[i].ToString()}");
                }
            }
        }