예제 #1
0
        public Flight GenerateFlight()
        {
            (City, City)cityPair = CityCatalog.GetRandomCityPair();

            Flight flight = new Flight
            {
                Type          = "Грузовой",
                DepartureCity = cityPair.Item1,
                ArrivalCity   = cityPair.Item2,
                RequiredLoad  = RoundOff(_random.Next(5000, 50000), 100),
                Forfeit       = RoundOff(_random.Next(1000000, 20000000), 1000000),
                PriceFlight   = RoundOff(_random.Next(100000, 3000000), 100000),
                FlightDate    = Game.Time.AddDays(_random.Next(1, 7)),
            };

            bool isPassenger = (_random.Next() % 2) == 0;

            if (isPassenger)
            {
                flight.Type           = "Пассажирский";
                flight.RequiredLoad   = RoundOff(_random.Next(20, 330), 1);
                flight.PricePassenger = RoundOff(_random.Next(2000, 10000), 250);
                flight.PriceFlight    = flight.PricePassenger * flight.RequiredLoad;
            }

            return(flight);
        }
예제 #2
0
        public TimeSpan GetFlyDuration(City a, City b)
        {
            int distance = CityCatalog.GetDistance(a, b);

            return(TimeSpan.FromHours(distance / Speed));
        }
예제 #3
0
 public bool CanFlyTo(City city) => city != Location &&
 CityCatalog.GetDistance(Location, city) <= DistanceFly;