/** * @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; } } } }