Exemple #1
0
        internal static void GetPassengerMenu(IFlight flight)
        {
            Console.WriteLine("Passenger menu.");
            Console.WriteLine("1. Add new passenger");
            Console.WriteLine("2. Edit existed passenger");
            Console.WriteLine("3. Delete passenger");

            byte mode    = 0;;
            bool TryByte = byte.TryParse(Console.ReadLine(), out mode);

            if (!TryByte)
            {
                Console.WriteLine("Incorrect input");
            }
            else
            {
                switch (mode)
                {
                case 1:
                    PassengerManager.AddPassenger(flight);
                    break;

                case 2:
                    PassengerManager.EditPassenger(flight);
                    break;

                case 3:
                    PassengerManager.DeletePassenger(flight.Passengers);
                    break;

                default:
                    Console.WriteLine("Incorrect input");
                    break;
                }
            }
        }
Exemple #2
0
        public static IFlight GenerateRandomFlight(IFlight[] flights)
        {
            DateTime dt = new DateTime();
            IFlight  flightsObject;

            string[] portCityTitle = new string[] { "Odessa", "Helsinki", "Munich", "Yuma", "Gdansk", "Oklahoma", "Dubai" };

            int monthRandom  = 0;
            int yearRandom   = 0;
            int dayRandom    = 0;
            int hourRandom   = 0;
            int minuteRandom = 0;
            int secondRandom = 0;

            //Date and Time
            yearRandom   = _randomValue(2015, 2017);
            monthRandom  = _randomValue(1, 13);
            hourRandom   = _randomValue(24);
            minuteRandom = _randomValue(60);
            secondRandom = _randomValue(60);


            if (monthRandom == 1 || monthRandom == 3 || monthRandom == 5 || monthRandom == 7 || monthRandom == 8 ||
                monthRandom == 10 || monthRandom == 12)
            {
                dayRandom = _randomValue(1, 32);
            }
            else if (monthRandom == 4 || monthRandom == 6 || monthRandom == 9 || monthRandom == 11)
            {
                dayRandom = _randomValue(1, 31);
            }
            else if (monthRandom == 2)
            {
                if (!DateTime.IsLeapYear(yearRandom))
                {
                    dayRandom = _randomValue(1, 29);
                }
                else
                {
                    dayRandom = _randomValue(1, 30);
                }
            }
            dt = new DateTime(yearRandom, monthRandom, dayRandom, hourRandom, minuteRandom, secondRandom);

            //Flight number
            bool check        = true;
            int  flightNumber = _randomValue(1, 1000);

            while (check)
            {
                if (Searcher.SearchByFlightNumber(flights, flightNumber) == null)
                {
                    break;
                }
                else
                {
                    flightNumber = _randomValue(100, 900);
                }
            }

            flightsObject = new Flight
            {
                TypeFlight     = (FlightType)_randomValue(2),
                FlightNumber   = flightNumber,
                FlightDT       = dt,
                PortCityTitle  = portCityTitle[_randomValue(7)],
                TerminalNumber = (byte)_randomValue(1, 15),
                StatusFlight   = (FlightStatus)_randomValue(9),
            };

            PassengerManager.FillPassengerArray(flightsObject, _randomValue(15));
            return(flightsObject);
        }