/** * @method Obtain the list of buyer names that have bought a maximum ticket order over several years. * @params None * @returns A list of all buyer names in this database representing buyers who have bought the maximum number of allowable tickets over several years. */ public HashSet <string> GetAffluentBuyerNames() { Dictionary <string, int> fullPurchasesByBuyerName = new Dictionary <string, int>(); // Iterate through all year and all buyers in all years. foreach (string yearNumber in YearNumbers) { Year year = GetYear(yearNumber); foreach (string buyerName in year.BuyerNames) { // Did this buyer buy the maximum number of tickets? if (year.GetBuyer(buyerName).HadFullAdultTicketOrder(yearNumber)) { // Add this user to our working dictionary. if (!fullPurchasesByBuyerName.ContainsKey(buyerName)) { fullPurchasesByBuyerName[buyerName] = 0; } ++fullPurchasesByBuyerName[buyerName]; } } } // Count the number of buyers who have maxed out their ticket orders across several years. HashSet <string> affluentBuyerNames = new HashSet <string>(); foreach (string buyerName in fullPurchasesByBuyerName.Keys) { if (fullPurchasesByBuyerName[buyerName] >= _configuration.GetAffluentBuyerYearThreshold()) { affluentBuyerNames.Add(buyerName); } } return(affluentBuyerNames); }