// called at startup - generates all the categories,with their products and prices. Generates all the fridays for that month. private void setUp() { allCategories.SetValue(Category.createInstance("Clothing and Accessories", CLOTHING_ACCESSORIES, CLOTHING_ACCESSORIES_PRICES, 10), 0); allCategories.SetValue(Category.createInstance("Electronics", ELECTRONICS, ELECTRONICS_PRICES, 10), 1); allCategories.SetValue(Category.createInstance("Automobile", AUTOMOBILE, AUTOMOBILE_PRICES, 10), 2); allCategories.SetValue(Category.createInstance("Food and Household", FOOD_HOUSEHOLD, FOOD_HOUSEHOLD_PRICES, 10), 3); tempFridayUtil = new FridayUtil(staticDateTime); allFridays = tempFridayUtil.allFridays; }
// prints products in category and displays appropriate discount for category if necessary. // Handles no discount scenario. public void categoryChoice(Category cat) { string strDiscount; if (FridayUtil.isFriday(staticDateTime)) { FridayUtil.fridaysOfTheMonth dt = tempFridayUtil.CheckFriday(staticDateTime); discount = getDiscount(dt); } else { discount = 0; } strDiscount = (discount * 100).ToString(); int i = 0; if (discount == 0) { Console.WriteLine("All Products in this category are not discounted!)"); Console.WriteLine("Discount for this Category will be on " + tempFridayUtil.getNearestFriday(staticDateTime)); } else { Console.WriteLine("All Products in this category are at a discounted price of {0}%(Black Friday Deals!!!)\n", strDiscount); } Array categoryProductNames = cat.getProductNames(); Array categoryProductPrices = cat.getProductPrices(); Console.WriteLine("Here are our Products for the day!\n"); while (i < categoryProductNames.Length) { double calculatedDiscount = ((double)categoryProductPrices.GetValue(i) - ((double)categoryProductPrices.GetValue(i) * discount)); //Console.WriteLine(productList[i] + "\nPrice -> {}", productPriceList[i]); Console.WriteLine($"{categoryProductNames.GetValue(i)} \nPrice {categoryProductPrices.GetValue(i)}"); if (discount != 0) { Console.Write($"Discounted Price -> {calculatedDiscount}\n\n"); } i++; } }