Пример #1
0
        //sets up the different scenario setting
        private static void SetupScenario()
        {
            Parallel.ForEach(Airports.GetAllAirports(), airport =>
            {
                foreach (Airline airline in Airlines.GetAllAirlines())
                {
                    foreach (AirportFacility.FacilityType type in Enum.GetValues(typeof(AirportFacility.FacilityType)))
                    {
                        AirportFacility noneFacility = AirportFacilities.GetFacilities(type).Find((delegate(AirportFacility facility) { return(facility.TypeLevel == 0); }));

                        airport.addAirportFacility(airline, noneFacility, GameObject.GetInstance().GameTime);
                    }
                }
                AirportHelpers.CreateAirportWeather(airport);
            });

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                if (airline.IsHuman)
                {
                    airline.Money = GameObject.GetInstance().StartMoney;
                }
                airline.StartMoney = airline.Money;
                airline.Fees       = new AirlineFees();
                airline.addAirlinePolicy(new AirlinePolicy("Cancellation Minutes", 150));
            }
        }
Пример #2
0
        public PageFlights()
        {
            this.Entries = Airlines.GetAllAirlines().SelectMany(a => a.Routes.SelectMany(r => r.TimeTable.Entries)).ToList();//.OrderBy(e => e.Time).ToList();
            sortCriteria = "Time";

            InitializeComponent();

            this.Uid   = "1000";
            this.Title = Translator.GetInstance().GetString("PageFlights", this.Uid);

            StackPanel flightsPanel = new StackPanel();

            flightsPanel.Margin = new Thickness(10, 0, 10, 0);

            flightsPanel.Children.Add(createDaysButtonsPanel());
            flightsPanel.Children.Add(createFlightsPanel());

            //  StandardContentPanel panelContent = new StandardContentPanel();

            //  panelContent.setContentPage(flightsPanel, StandardContentPanel.ContentLocation.Left);

            //   StackPanel panelSideMenu = new PanelAirport(this.Airport);

            //   panelContent.setContentPage(panelSideMenu, StandardContentPanel.ContentLocation.Right);

            base.setContent(flightsPanel);

            base.setHeaderContent(this.Title);

            showPage(this);

            day = GameObject.GetInstance().GameTime.DayOfWeek;
            showDayEntries();
        }
Пример #3
0
        public PageFlights()
        {
            this.AllFlights = Airlines.GetAllAirlines().SelectMany(a => a.Routes.SelectMany(r => r.TimeTable.Entries)).ToList();
            InitializeComponent();

            this.Loaded += PageFlights_Loaded;
        }
        private void txtIATA_TextChanged(object sender, TextChangedEventArgs e)
        {
            Boolean IATAExits       = Airlines.GetAllAirlines().Find(a => a.Profile.IATACode == txtIATA.Text.ToUpper()) != null;
            Boolean airportSelected = cbAirport.SelectedItem != null;

            btnOk.IsEnabled = txtIATA.Text.Trim().Length == 2 && txtAirlineName.Text.Trim().Length > 2 && !IATAExits && airportSelected;
        }
Пример #5
0
        //creates the page
        private void createPage(List <Airport> airports)
        {
            this.AllAirlines      = new List <Airline>();
            this.SelectedAirports = new ObservableCollection <AirportMVVM>();
            this.RoutesRanges     = new List <FilterValue>()
            {
                new FilterValue("0", 0, 0), new FilterValue("1-9", 1, 9), new FilterValue("10-24", 10, 24), new FilterValue("25+", 25, int.MaxValue)
            };
            this.OperatingRanges = new List <FilterValue>()
            {
                new FilterValue("0", 0, 0), new FilterValue("1-5", 1, 5), new FilterValue("6+", 5, int.MaxValue)
            };

            Airline dummyAirline = new Airline(new AirlineProfile("All Airlines", "99", "Blue", "", false, 1900, 1900), Airline.AirlineMentality.Safe, Airline.AirlineFocus.Domestic, Airline.AirlineLicense.Domestic, Route.RouteType.Passenger);

            dummyAirline.Profile.addLogo(new AirlineLogo(AppSettings.getDataPath() + "\\graphics\\airlinelogos\\default.png"));

            this.AllAirlines.Add(dummyAirline);

            foreach (Airline airline in Airlines.GetAllAirlines().Where(a => a != GameObject.GetInstance().HumanAirline).OrderBy(a => a.Profile.Name))
            {
                this.AllAirlines.Add(airline);
            }

            this.AllAirports = new List <AirportMVVM>();

            foreach (Airport airport in airports.OrderBy(a => a.Profile.Name))
            {
                this.AllAirports.Add(new AirportMVVM(airport));
            }

            AirlinerType dummyAircraft = new AirlinerCargoType(new Manufacturer("Dummy", "", null, false), "All Aircrafts", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, AirlinerType.BodyType.Single_Aisle, AirlinerType.TypeRange.Regional, AirlinerType.EngineType.Jet, new Period <DateTime>(DateTime.Now, DateTime.Now), 0, false);

            this.HumanAircrafts = new List <AirlinerType>();

            this.HumanAircrafts.Add(dummyAircraft);


            foreach (AirlinerType type in GameObject.GetInstance().HumanAirline.Fleet.Select(f => f.Airliner.Type).Distinct())
            {
                this.HumanAircrafts.Add(type);
            }

            InitializeComponent();


            TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu");

            if (tab_main != null)
            {
                var matchingItem =
                    tab_main.Items.Cast <TabItem>()
                    .Where(item => item.Tag.ToString() == "Airports")
                    .FirstOrDefault();

                //matchingItem.IsSelected = true;
                tab_main.SelectedItem = matchingItem;
            }
        }
Пример #6
0
        public PopUpInviteAlliance(Alliance alliance)
        {
            this.InviteAirlines = new List <Airline>();

            this.Alliance = alliance;
            InitializeComponent();

            this.Title = this.Alliance.Name;

            this.Width = 300;

            this.Height = 500;

            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            StackPanel panelMain = new StackPanel();

            ScrollViewer scroller = new ScrollViewer();

            scroller.MaxHeight = this.Height - 50;
            scroller.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;

            panelMain.Children.Add(scroller);

            StackPanel panelAirlines = new StackPanel();

            scroller.Content = panelAirlines;

            var airlines = from a in Airlines.GetAllAirlines() where !this.Alliance.Members.ToList().Exists(m => m.Airline == a) select a;

            foreach (Airline airline in airlines)
            {
                WrapPanel panelAirline = new WrapPanel();
                panelAirline.Margin = new Thickness(0, 0, 0, 5);

                ContentControl ccAirline = new ContentControl();
                ccAirline.ContentTemplate = this.Resources["AirlineItem"] as DataTemplate;
                ccAirline.Content         = airline;

                panelAirline.Children.Add(ccAirline);

                CheckBox cbAirline = new CheckBox();
                cbAirline.IsChecked         = false;
                cbAirline.Tag               = airline;
                cbAirline.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
                cbAirline.Checked          += new RoutedEventHandler(cbAirline_Checked);
                cbAirline.Unchecked        += new RoutedEventHandler(cbAirline_Unchecked);

                panelAirline.Children.Add(cbAirline);

                panelAirlines.Children.Add(panelAirline);
            }

            panelMain.Children.Add(createButtonsPanel());

            this.Content = panelMain;
        }
Пример #7
0
        private void cbDestination_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cbDestination1 != null && cbDestination2 != null && txtDistance != null)
            {
                Airport destination1 = (Airport)cbDestination1.SelectedItem;
                Airport destination2 = (Airport)cbDestination2.SelectedItem;

                if (destination1 != null && destination2 != null)
                {
                    foreach (MVVMRouteClass rClass in this.Classes)
                    {
                        rClass.FarePrice = PassengerHelpers.GetPassengerPrice(destination1, destination2) * GeneralHelpers.ClassToPriceFactor(rClass.Type);
                    }

                    txtDistance.Text = new DistanceToUnitConverter().Convert(MathHelpers.GetDistance(destination1, destination2)).ToString();

                    var codesharingRoutes     = GameObject.GetInstance().HumanAirline.Codeshares.Where(c => c.Airline2 == GameObject.GetInstance().HumanAirline || c.Type == Model.AirlineModel.CodeshareAgreement.CodeshareType.Both_Ways).Select(c => c.Airline1 == GameObject.GetInstance().HumanAirline ? c.Airline2 : c.Airline1).SelectMany(a => a.Routes);
                    var humanConnectingRoutes = GameObject.GetInstance().HumanAirline.Routes.Where(r => r.Destination1 == destination1 || r.Destination2 == destination1 || r.Destination1 == destination2 || r.Destination2 == destination2);

                    var codesharingConnectingRoutes = codesharingRoutes.Where(r => r.Destination1 == destination1 || r.Destination2 == destination1 || r.Destination1 == destination2 || r.Destination2 == destination2);

                    this.ConnectingRoutes.Clear();

                    foreach (Route route in humanConnectingRoutes)
                    {
                        this.ConnectingRoutes.Add(route);
                    }

                    foreach (Route route in codesharingConnectingRoutes)
                    {
                        this.ConnectingRoutes.Add(route);
                    }

                    var opponentRoutes = Airlines.GetAllAirlines().Where(a => !a.IsHuman).SelectMany(a => a.Routes).Where(r => (r.Destination1 == destination1 && r.Destination2 == destination2) || (r.Destination2 == destination1 && r.Destination1 == destination2));

                    if (opponentRoutes.Count() == 0)
                    {
                        this.RouteInformationText = "";
                    }
                    else
                    {
                        var airlines = opponentRoutes.Select(r => r.Airline).Distinct();

                        if (airlines.Count() == 1)
                        {
                            this.RouteInformationText = string.Format("{0} also operates a route between {1} and {2}", airlines.ElementAt(0).Profile.Name, destination1.Profile.Name, destination2.Profile.Name);
                        }
                        else
                        {
                            this.RouteInformationText = string.Format("{0} other airlines do also operate a route between {1} and {2}", airlines.Count(), destination1.Profile.Name, destination2.Profile.Name);
                        }
                    }
                }
            }
        }
Пример #8
0
        //returns all airline luxury levels
        private static Dictionary <Airline, Double> GetAirlinesLuxuryLevels()
        {
            Dictionary <Airline, Double> values = new Dictionary <Airline, Double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                values.Add(airline, GetAirlineLuxuryLevel(airline));
            }

            return(values);
        }
Пример #9
0
        //returns the average fill degree of all airlines
        //FINISHED
        public static Double GetFillAverage()
        {
            List <Double> fillDegrees = new List <Double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                List <Double> fillDegree = (from r in airline.Routes select r.getFillingDegree()).ToList();
                fillDegrees.Add(fillDegree.DefaultIfEmpty(0).Average());
            }
            return(fillDegrees.DefaultIfEmpty(0).Average());
        }
Пример #10
0
        //returns dictionary of all airline average on-time %
        public static Dictionary <Airline, Double> GetTotalOnTime()
        {
            Dictionary <Airline, Double> totalOnTime = new Dictionary <Airline, Double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                double otp = airline.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("On-Time%"));
                totalOnTime.Add(airline, otp);
            }
            return(totalOnTime);
        }
Пример #11
0
        //returns a dictionary of unassigned pilots
        public static Dictionary <Airline, Double> GetUnassignedPilots()
        {
            Dictionary <Airline, Double> unassignedPilots = new Dictionary <Airline, Double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                double unPilots = airline.Pilots.Count(p => p.Airliner == null);
                unassignedPilots.Add(airline, unPilots);
            }
            return(unassignedPilots);
        }
Пример #12
0
        public PageAirlines()
        {
            var airlines = Airlines.GetAllAirlines();

            this.MostGates    = airlines.OrderByDescending(a => a.Airports.Sum(c => c.AirlineContracts.Where(ac => ac.Airline == a).Sum(ac => ac.NumberOfGates))).Take(Math.Min(5, airlines.Count)).ToList();
            this.MostRoutes   = airlines.OrderByDescending(a => a.Routes.Count).Take(Math.Min(airlines.Count, 5)).ToList();
            this.LargestFleet = airlines.OrderByDescending(a => a.Fleet.Count).Take(Math.Min(airlines.Count, 5)).ToList();

            this.Loaded += PageAirlines_Loaded;
            InitializeComponent();
        }
Пример #13
0
        //creates a dictionary of average employee discounts
        public static Dictionary <Airline, Double> GetEmployeeDiscounts()
        {
            Dictionary <Airline, Double> employeeDiscounts = new Dictionary <Airline, double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                double eDiscount = airline.Fees.getValue(FeeTypes.GetType("Employee Discount"));
                employeeDiscounts.Add(airline, eDiscount);
            }
            return(employeeDiscounts);
        }
Пример #14
0
        //returns dictionary of average fill degrees for all airlines
        //FINISHED
        public static Dictionary <Airline, Double> GetFillAverages()
        {
            Dictionary <Airline, Double> fillAverage = new Dictionary <Airline, Double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                List <Double> fillDegree  = (from r in airline.Routes where r.Type == Route.RouteType.Mixed || r.Type == Route.RouteType.Passenger select((PassengerRoute)r).getFillingDegree()).ToList();
                double        uFillDegree = fillDegree.DefaultIfEmpty(0).Average();
                fillAverage.Add(airline, uFillDegree);
            }
            return(fillAverage);
        }
Пример #15
0
        //returns the number of routes between two airports
        public static int GetNumberOfAirportsRoutes(Airport airport1, Airport airport2)
        {
            int count  = 0;
            var routes = Airlines.GetAllAirlines().SelectMany(a => a.Routes);

            lock (routes)
            {
                count = routes.Count(r => (r.Destination1 == airport1 && r.Destination2 == airport2) || (r.Destination1 == airport2 && r.Destination2 == airport1));
            }

            return(count);
        }
        //creates the airlines statistics
        private StackPanel createStatisticsPanel(StatisticsType type, Boolean inPercent)
        {
            StackPanel panelStatistics = new StackPanel();

            panelStatistics.Margin = new Thickness(0, 0, 0, 5);

            ContentControl ccHeader = new ContentControl();

            ccHeader.ContentTemplate = this.Resources["StatHeader"] as DataTemplate;
            ccHeader.Content         = new KeyValuePair <StatisticsType, KeyValuePair <int, int> >(type, new KeyValuePair <int, int>(GameObject.GetInstance().GameTime.Year - 1, GameObject.GetInstance().GameTime.Year));
            panelStatistics.Children.Add(ccHeader);

            ListBox lbStats = new ListBox();

            lbStats.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbStats.ItemTemplate = inPercent ? this.Resources["StatPercentItem"] as DataTemplate : this.Resources["StatItem"] as DataTemplate;

            List <Airline> airlines = Airlines.GetAllAirlines().FindAll(a => !a.IsSubsidiary);

            airlines.Sort((delegate(Airline a1, Airline a2) { return(a1.Profile.Name.CompareTo(a2.Profile.Name)); }));

            List <KeyValuePair <Airline, StatisticsType> > values = new List <KeyValuePair <Airline, StatisticsType> >();

            foreach (Airline airline in airlines)
            {
                values.Add(new KeyValuePair <Airline, StatisticsType>(airline, type));
                foreach (SubsidiaryAirline sAirline in airline.Subsidiaries)
                {
                    values.Add(new KeyValuePair <Airline, StatisticsType>(sAirline, type));
                }
            }

            lbStats.ItemsSource = values;

            panelStatistics.Children.Add(lbStats);

            lbToUpdate.Add(lbStats);

            /*
             * if (!inPercent)
             * {
             *  ContentControl ccTotal = new ContentControl();
             *  ccTotal.Margin = new Thickness(5, 0, 0, 0);
             *  ccTotal.ContentTemplate = this.Resources["StatTotalItem"] as DataTemplate;
             *  ccTotal.Content = type;
             *
             *  panelStatistics.Children.Add(ccTotal);
             * }
             * */

            return(panelStatistics);
        }
Пример #17
0
        //returns if there is a route between two airports
        public static Boolean HasRoute(Airport airport1, Airport airport2)
        {
            var airlines = new List <Airline>(Airlines.GetAllAirlines());

            var routes = new List <Route>();

            foreach (Airline airline in airlines)
            {
                routes.AddRange(airline.Routes);
            }

            return(routes.Where(r => (r.Destination1 == airport1 && r.Destination2 == airport2) || (r.Destination1 == airport2 && r.Destination2 == airport1)).Count() > 0);
        }
        //creates the airlines statistics
        private StackPanel createStatisticsPanel(string methodName, string name, Boolean financial)
        {
            StackPanel panelStatistics = new StackPanel();

            panelStatistics.Margin = new Thickness(0, 0, 0, 5);

            TextBlock txtHeader = new TextBlock();

            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush");
            txtHeader.FontWeight = FontWeights.Bold;
            txtHeader.Text       = name;

            panelStatistics.Children.Add(txtHeader);

            ListBox lbStatistics = new ListBox();

            lbStatistics.ItemContainerStyleSelector = new ListBoxItemStyleSelector();


            // chs, 2011-22-10 changed so financial statistics are shown in currency
            if (financial)
            {
                lbStatistics.ItemTemplate = this.Resources["AirlineFinancialStatItem"] as DataTemplate;
            }
            else
            {
                lbStatistics.ItemTemplate = this.Resources["AirlineStatItem"] as DataTemplate;
            }


            double maxValue = getMaxValue(methodName);

            double coff = this.StatWidth / maxValue;

            List <Airline> airlines = Airlines.GetAllAirlines();

            airlines.Sort((delegate(Airline a1, Airline a2) { return(a1.Profile.Name.CompareTo(a2.Profile.Name)); }));

            foreach (Airline airline in airlines)
            {
                MethodInfo method = typeof(Airline).GetMethod(methodName);
                double     value  = (double)method.Invoke(airline, null);

                lbStatistics.Items.Add(new AirlineStatisticsItem(airline, (int)value, Math.Max(1, (int)Convert.ToDouble(value * coff))));
            }

            panelStatistics.Children.Add(lbStatistics);

            return(panelStatistics);
        }
Пример #19
0
        //returns the average employee wages
        public static double GetAverageEmployeeWages()
        {
            var numberOfAirlines = Airlines.GetNumberOfAirlines();
            Dictionary <Airline, Double> airlineWages = new Dictionary <Airline, double>(GetEmployeeWages());

            double totalWages = 0;

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                totalWages += GetEmployeeWages()[airline];
            }

            return(totalWages / numberOfAirlines);
        }
Пример #20
0
 //checks if an event's effects are expired
 public static void CheckExpired(DateTime expDate)
 {
     foreach (Airline airline in Airlines.GetAllAirlines())
     {
         foreach (RandomEvent rEvent in airline.EventLog)
         {
             expDate = GameObject.GetInstance().GameTime.AddMonths(rEvent.EffectLength);
             if (expDate < GameObject.GetInstance().GameTime)
             {
                 PassengerHelpers.ChangePaxDemand(airline, (1 / rEvent.PaxDemandEffect));
                 RemoveEvent(airline, rEvent);
             }
         }
     }
 }
Пример #21
0
        public PageAirlinesStatistics()
        {
            this.AllAirlines = new ObservableCollection <AirlinesMVVM>();

            foreach (Airline airline in Airlines.GetAllAirlines().FindAll(a => !a.IsSubsidiary).OrderByDescending(a => a.IsHuman))
            {
                this.AllAirlines.Add(new AirlinesMVVM(airline));

                foreach (SubsidiaryAirline sAirline in airline.Subsidiaries)
                {
                    this.AllAirlines.Add(new AirlinesMVVM(sAirline));
                }
            }

            InitializeComponent();
        }
Пример #22
0
        //returns dictionary of overall ticket price per distance
        public static Dictionary <Airline, Double> GetTotalPPD()
        {
            List <Double> ticketPPD = new List <Double>();
            Dictionary <Airline, Double> uDistPrice = new Dictionary <Airline, Double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                List <Double> econPrices   = (from r in airline.Routes where r.Type == Route.RouteType.Passenger || r.Type == Route.RouteType.Mixed select((PassengerRoute)r).getFarePrice(AirlinerModel.AirlinerClass.ClassType.Economy_Class)).ToList();
                List <Double> busPrices    = (from r in airline.Routes where r.Type == Route.RouteType.Passenger || r.Type == Route.RouteType.Mixed select((PassengerRoute)r).getFarePrice(AirlinerModel.AirlinerClass.ClassType.Business_Class)).ToList();
                List <Double> firstPrices  = (from r in airline.Routes where r.Type == Route.RouteType.Passenger || r.Type == Route.RouteType.Mixed select((PassengerRoute)r).getFarePrice(AirlinerModel.AirlinerClass.ClassType.First_Class)).ToList();
                List <Double> distance     = (from r in airline.Routes select MathHelpers.GetDistance(r.Destination1, r.Destination2)).ToList();
                double        avgDistPrice = ((econPrices.DefaultIfEmpty(0).Average() * 0.7) + (busPrices.DefaultIfEmpty(0).Average() * 0.2) + (firstPrices.DefaultIfEmpty(0).Average() * 0.1)) / distance.DefaultIfEmpty(0).Average();
                uDistPrice.Add(airline, avgDistPrice);
            }
            return(uDistPrice);
        }
Пример #23
0
        public PageShowAlliances()
        {
            this.AllAlliances = Alliances.GetAlliances();

            this.AllCodesharings = new ObservableCollection <CodeshareAgreementMVVM>();

            var codesharings = Airlines.GetAllAirlines().SelectMany(a => a.Codeshares).Distinct();

            foreach (CodeshareAgreement agreement in codesharings)
            {
                this.AllCodesharings.Add(new CodeshareAgreementMVVM(agreement));
            }

            InitializeComponent();

            this.Loaded += PageShowAlliances_Loaded;
        }
Пример #24
0
        //finds the maximum value for a type
        private long getMaxValue(string methodName)
        {
            long value = 1;

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                MethodInfo method = typeof(Airline).GetMethod(methodName);
                object     v      = method.Invoke(airline, null);

                if (Convert.ToInt64(v) > value)
                {
                    value = Convert.ToInt64(v);
                }
            }

            return(value);
        }
        //finds the maximum value for a type
        private double getMaxValue(string methodName)
        {
            double value = 1;

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                MethodInfo method = typeof(Airline).GetMethod(methodName);
                double     aValue = (double)method.Invoke(airline, null);

                if (aValue > value)
                {
                    value = aValue;
                }
            }

            return(value);
        }
Пример #26
0
        //returns the average employee wages for the competitors for an airlines
        public static double GetAverageEmployeeWages(Airline airline)
        {
            var numberOfAirlines = Airlines.GetNumberOfAirlines() - 1;
            Dictionary <Airline, Double> airlineWages = new Dictionary <Airline, double>(GetEmployeeWages());

            double totalWages = 0;

            foreach (Airline competitor in Airlines.GetAllAirlines())
            {
                if (competitor != airline)
                {
                    totalWages += GetEmployeeWages()[competitor];
                }
            }

            return(totalWages / numberOfAirlines);
        }
Пример #27
0
 private void bw_DoWork(object sender, DoWorkEventArgs e)
 {
     foreach (Airline airline in Airlines.GetAllAirlines())
     {
         if ((this.Worker.CancellationPending == true))
         {
             e.Cancel = true;
         }
         else
         {
             if (!airline.IsHuman)
             {
                 AIHelpers.UpdateCPUAirline(airline);
             }
         }
     }
 }
Пример #28
0
        //calculates maximum difference
        public static Dictionary <Airline, Double> GetPPDdifference()
        {
            Dictionary <Airline, Double> ppdDifference = new Dictionary <Airline, Double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                double        avgPPD = 0; // GetTotalTicketPPD();
                List <Double> aiEconPrices = (from r in airline.Routes where r.Type == Route.RouteType.Passenger || r.Type == Route.RouteType.Mixed select((PassengerRoute)r).getFarePrice(AirlinerModel.AirlinerClass.ClassType.Economy_Class)).ToList();
                List <Double> aiBusPrices = (from r in airline.Routes where r.Type == Route.RouteType.Passenger || r.Type == Route.RouteType.Mixed select((PassengerRoute)r).getFarePrice(AirlinerModel.AirlinerClass.ClassType.Business_Class)).ToList();
                List <Double> aiFirstPrices = (from r in airline.Routes where r.Type == Route.RouteType.Passenger || r.Type == Route.RouteType.Mixed select((PassengerRoute)r).getFarePrice(AirlinerModel.AirlinerClass.ClassType.First_Class)).ToList();
                double        distance = (from r in airline.Routes select MathHelpers.GetDistance(r.Destination1, r.Destination2)).DefaultIfEmpty(0).Average();
                double        avgEP = aiEconPrices.DefaultIfEmpty(0).Average(); double avgBP = aiBusPrices.DefaultIfEmpty(0).Average(); double avgFP = aiFirstPrices.DefaultIfEmpty(0).Average();
                double        avgDistPrice = ((avgEP * 0.7) + (avgBP * 0.2) + (avgFP * 0.1)) / distance;
                double        avgDiff      = avgDistPrice - avgPPD;
                ppdDifference.Add(airline, avgDiff);
            }
            return(ppdDifference);
        }
Пример #29
0
        //returns all routes between two airports
        public static List <Route> GetAirportRoutes(Airport airport1, Airport airport2)
        {
            var airlines = new List <Airline>(Airlines.GetAllAirlines());

            var routes = new List <Route>();

            foreach (Airline airline in airlines)
            {
                lock (airline.Routes)
                {
                    var aRoutes = new List <Route>(airline.Routes);

                    foreach (Route route in aRoutes)
                    {
                        routes.Add(route);
                    }
                }
            }
            return(routes.Where(r => (r.Destination1 == airport1 && r.Destination2 == airport2) || (r.Destination1 == airport2 && r.Destination2 == airport1)).ToList());
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            StatisticsType stat = (StatisticsType)value;

            int year = Int16.Parse(parameter.ToString());



            double lastYearValue    = Airlines.GetAllAirlines().Sum(a => a.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year - 1, stat));
            double currentYearValue = Airlines.GetAllAirlines().Sum(a => a.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, stat));


            if (year == 0)
            {
                return(currentYearValue);
            }
            else if (year == -1)
            {
                return(lastYearValue);
            }
            else
            {
                if (lastYearValue == 0)
                {
                    return("100.00 %");
                }
                double changePercent = System.Convert.ToDouble(currentYearValue - lastYearValue) / lastYearValue;

                if (double.IsInfinity(changePercent))
                {
                    return("100.00 %");
                }
                if (double.IsNaN(changePercent))
                {
                    return("-");
                }

                return(string.Format("{0:0.00} %", changePercent * 100));
            }
        }