/**
         * @method Build a potential future outcome given a scenario and based on a past year.
         * @param basedOnYearNumber - The outcome will be based on the historical data in the given year.
         * @param outcome - This object will be populated with the results of this computation.
         * @param scenario - If this is null, the values held in the given year will be populated in the outcome.
         *      If it is not null, the outcome will take the parameters of the scenario into question.
         * @returns None; the outcome variable will have its member values set.
         */
        private void DetermineOutcome(string basedOnYearNumber, ProjectedFuture.Outcome outcome, ProjectionScenario scenario)
        {
            // Copy historical data from this year.
            outcome.ExpectedTotalTicketBuyers    = _database.GetBuyerCountForYear(basedOnYearNumber);
            outcome.TotalAdultTicketsSold        = _database.GetTicketCountForYear(basedOnYearNumber);
            outcome.TotalAdultTicketsTransferred = _database.GetSoldTicketCountForYear(basedOnYearNumber);

            // If we have a null scenario, just plug the values for this outcome that occurred in the given year.
            if (scenario == null)
            {
                return;
            }

            // Does the scenario include a different ticket cap?
            if (scenario.TicketCap.HasValue)
            {
                // Project into the future.
                outcome.ExpectedTotalTicketBuyers    = _database.GetBuyerCountForYear(basedOnYearNumber);
                outcome.TotalAdultTicketsSold        = 0;
                outcome.TotalAdultTicketsTransferred = 0;

                // Determine the future behavior of affluent buyers
                HashSet <string> affluentUserNames = _database.GetAffluentBuyerNames();
                Data.Year        year = _database.GetYear(basedOnYearNumber);

                // Iterate over the buyers in this year.
                foreach (string buyerName in year.BuyerNames)
                {
                    // Is this an affluent buyer?
                    bool isAffluent = affluentUserNames.Contains(buyerName);

                    // If this is an affluent buyer, assume that they will buy the max tickets and sell all but 1.
                    if (isAffluent)
                    {
                        outcome.TotalAdultTicketsSold        += scenario.TicketCap.Value;
                        outcome.TotalAdultTicketsTransferred += scenario.TicketCap.Value - 1;
                    }
                    else
                    {
                        // Otherwise, just repeat this buyer's behavior.
                        Data.Buyer buyer = year.GetBuyer(buyerName);
                        outcome.TotalAdultTicketsSold        += buyer.AdultTicketCount;
                        outcome.TotalAdultTicketsTransferred += buyer.SoldAdultTicketCount;
                    }
                }
            }
        }
Exemple #2
0
        public void Run()
        {
            Console.WriteLine("Running application with mocked test data...");

            /**
             * Dossier
             *
             * Family Buyers: buys the maximum number of tickets and sells none of them
             *      Kind Kim
             *      Family-Minded Fanny
             *
             * Affluent Buyers: buys the maximum number of tickets each year and sells all but one
             *      Affluent Alice
             *      Rich Rich
             *
             * Scalper Buyers: buys the maximum number of tickets and sells all of them
             *      Scalper Sam
             *      Lame Lenny
             *
             * Unfortunate Buyers: buys one ticket and has to sell it to someone else
             *      Sad Sally
             *      Melancholy Melanie
             *
             * Normal Buyers: buys one ticket and does not sell it
             *      Burner Bob
             *      Sparkle Pony
             */

            // Add some junk data to this database for testing.

            // 2016 data
            string year;

            year = "2016";
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Ticket 1");
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Ticket 2");
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Child Ticket 1").IsChildTicket = true;
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Child Ticket 2").IsChildTicket = true;

            _database.GetYear(year).GetBuyer("Affluent Alice").GetTicket("Ticket 3");
            _database.GetYear(year).GetBuyer("Affluent Alice").GetTicket("Ticket 4").WasTransacted();

            _database.GetYear(year).GetBuyer("Scalper Sam").GetTicket("Ticket 5").WasTransacted();
            _database.GetYear(year).GetBuyer("Scalper Sam").GetTicket("Ticket 6").WasTransacted();

            _database.GetYear(year).GetBuyer("Melancholy Melanie").GetTicket("Ticket 7").WasTransacted();

            _database.GetYear(year).GetBuyer("Burner Bob").GetTicket("Ticket 8");
            _database.GetYear(year).GetBuyer("Sparkle Pony").GetTicket("Ticket 9");

            // 2017 data
            year = "2017";
            _database.GetYear(year).GetBuyer("Family-Minded Fanny").GetTicket("Ticket 1");
            _database.GetYear(year).GetBuyer("Family-Minded Fanny").GetTicket("Ticket 2");
            _database.GetYear(year).GetBuyer("Family-Minded Fanny").GetTicket("Child Ticket 1").IsChildTicket = true;
            _database.GetYear(year).GetBuyer("Family-Minded Fanny").GetTicket("Child Ticket 2").IsChildTicket = true;
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Ticket 3");
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Ticket 4");
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Child Ticket 3").IsChildTicket = true;

            _database.GetYear(year).GetBuyer("Affluent Alice").GetTicket("Ticket 5");
            _database.GetYear(year).GetBuyer("Affluent Alice").GetTicket("Ticket 6").WasTransacted();
            _database.GetYear(year).GetBuyer("Rich Rich").GetTicket("Ticket 7");
            _database.GetYear(year).GetBuyer("Rich Rich").GetTicket("Ticket 8").WasTransacted();

            _database.GetYear(year).GetBuyer("Lame Lenny").GetTicket("Ticket 9").WasTransacted();
            _database.GetYear(year).GetBuyer("Lame Lenny").GetTicket("Ticket 10").WasTransacted();

            _database.GetYear(year).GetBuyer("Melancholy Melanie").GetTicket("Ticket 11").WasTransacted();
            _database.GetYear(year).GetBuyer("Sad Sally").GetTicket("Ticket 12").WasTransacted();

            _database.GetYear(year).GetBuyer("Burner Bob").GetTicket("Ticket 13");
            _database.GetYear(year).GetBuyer("Sparkle Pony").GetTicket("Ticket 14");

            // 2018 data
            year = "2018";
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Ticket 1");
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Ticket 2");
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Child Ticket 1").IsChildTicket = true;
            _database.GetYear(year).GetBuyer("Kind Kim").GetTicket("Child Ticket 2").IsChildTicket = true;
            _database.GetYear(year).GetBuyer("Family-Minded Fanny").GetTicket("Ticket 3");
            _database.GetYear(year).GetBuyer("Family-Minded Fanny").GetTicket("Ticket 4");
            _database.GetYear(year).GetBuyer("Family-Minded Fanny").GetTicket("Child Ticket 3").IsChildTicket = true;

            _database.GetYear(year).GetBuyer("Affluent Alice").GetTicket("Ticket 5");
            _database.GetYear(year).GetBuyer("Affluent Alice").GetTicket("Ticket 6").WasTransacted();
            _database.GetYear(year).GetBuyer("Rich Rich").GetTicket("Ticket 7");
            _database.GetYear(year).GetBuyer("Rich Rich").GetTicket("Ticket 8").WasTransacted();

            _database.GetYear(year).GetBuyer("Scalper Sam").GetTicket("Ticket 9").WasTransacted();
            _database.GetYear(year).GetBuyer("Scalper Sam").GetTicket("Ticket 10").WasTransacted();
            _database.GetYear(year).GetBuyer("Lame Lenny").GetTicket("Ticket 11").WasTransacted();
            _database.GetYear(year).GetBuyer("Lame Lenny").GetTicket("Ticket 12").WasTransacted();

            _database.GetYear(year).GetBuyer("Melancholy Melanie").GetTicket("Ticket 13").WasTransacted();

            _database.GetYear(year).GetBuyer("Burner Bob").GetTicket("Ticket 14");
            _database.GetYear(year).GetBuyer("Sparkle Pony").GetTicket("Ticket 15");
        }