public static string GetExactMarketReport(CakeryRoom.MarketReport marketReport, CakeryRoom.Prices prices) { StringBuilder newsReport = new StringBuilder(); (var cookiesSold, var croissantsSold, var cakesSold) = marketReport.TotalSales; (var expectedCookies, var expectedCroissants, var expectedCakes) = CakeryRoom.ComputeExpectedSales(marketReport.CashInPreviousRound, marketReport.EfficiencyCoefficient); var cookiePercentageSold = cookiesSold / (expectedCookies != 0 ? expectedCookies : 0.1); var croissantPercentageSold = croissantsSold / (expectedCroissants != 0 ? expectedCroissants : 0.1); var cakePercentageSold = cakesSold / (expectedCakes != 0 ? expectedCakes : 0.1); newsReport.AppendLine("All goods sold this round: "); if (cookiesSold > 0) { newsReport.AppendLine($"{cookiesSold} Cookies " + $"sold for {(marketReport.Prices.cookiePrice/100).ToString("C")}" + $" ({(prices.Cookies / 100).ToString("C")} x {(int)(marketReport.Prices.cookiePrice * 100 / prices.Cookies)}%). "); } if (croissantsSold > 0) { newsReport.AppendLine($"{croissantsSold} Croissants " + $"sold for {(marketReport.Prices.croissantPrice / 100).ToString("C")}" + $" ({(prices.Croissants / 100).ToString("C")} x {(int)(marketReport.Prices.croissantPrice * 100 / prices.Croissants)}%). "); } if (cakesSold > 0) { newsReport.AppendLine($"{cakesSold} Cakes " + $"sold for {(marketReport.Prices.cakePrice / 100).ToString("C")}" + $" ({(prices.Cakes / 100).ToString("C")} x {(int)(marketReport.Prices.cakePrice * 100 / prices.Cakes)}%). "); } if (cakesSold == 0 && cookiesSold == 0 && croissantsSold == 0) { return("No goods were sold this round. "); } return(newsReport.ToString()); }
public static string GetNewsReport(CakeryRoom.MarketReport marketReport, CakeryRoom.Prices prices) { (var cookiesSold, var croissantsSold, var cakesSold) = marketReport.TotalSales; (var expectedCookies, var expectedCroissants, var expectedCakes) = CakeryRoom.ComputeExpectedSales(marketReport.CashInPreviousRound, marketReport.EfficiencyCoefficient); var cookiePercentageSold = cookiesSold / (expectedCookies != 0 ? expectedCookies : 0.1); var croissantPercentageSold = croissantsSold / (expectedCroissants != 0 ? expectedCroissants : 0.1); var cakePercentageSold = cakesSold / (expectedCakes != 0 ? expectedCakes : 0.1); StringBuilder newsReport = new StringBuilder(); if (cookiePercentageSold < 0.2 && marketReport.TotalSales.cookiesSold > 0) { newsReport.AppendLine(cookiesVeryLow); } else if (cookiePercentageSold < 0.45 && marketReport.TotalSales.cookiesSold > 0) { newsReport.AppendLine(cookiesQuiteLow); } else if (cookiePercentageSold > 1.3 && marketReport.TotalSales.cookiesSold > 0) { newsReport.Append(cookiesQuiteHigh); } else if (cookiePercentageSold > 1.8 && marketReport.TotalSales.cookiesSold > 0) { newsReport.Append(cookiesVeryHigh); } if (croissantPercentageSold < 0.2 && marketReport.TotalSales.croissantsSold > 0) { newsReport.AppendLine(croissantsVeryLow); } else if (croissantPercentageSold < 0.45 && marketReport.TotalSales.croissantsSold > 0) { newsReport.AppendLine(croissantsQuiteLow); } else if (croissantPercentageSold > 1.3 && marketReport.TotalSales.croissantsSold > 0) { newsReport.Append(croissantsQuiteHigh); } else if (croissantPercentageSold > 1.8 && marketReport.TotalSales.croissantsSold > 0) { newsReport.Append(croissantsVeryHigh); } if (cakePercentageSold < 0.2 && marketReport.TotalSales.cakesSold > 0) { newsReport.AppendLine(cakesVeryLow); } else if (cakePercentageSold < 0.45 && marketReport.TotalSales.cakesSold > 0) { newsReport.AppendLine(cakesQuiteLow); } else if (cakePercentageSold > 1.3 && marketReport.TotalSales.cakesSold > 0) { newsReport.Append(cakesQuiteHigh); } else if (cakePercentageSold > 1.8 && marketReport.TotalSales.cakesSold > 0) { newsReport.Append(cakesVeryHigh); } newsReport.Append($" Cookie Prices: {(int)(marketReport.Prices.cookiePrice * 100 / prices.Cookies)}%, " + $"Croissant Prices: {(int)(marketReport.Prices.croissantPrice * 100 / prices.Croissants)}% " + $"Cake Prices: {(int)(marketReport.Prices.cakePrice * 100 / prices.Cakes)}% "); return(newsReport.ToString()); }