// ustawienie rozmiaru okna, wyświetlenie menu statystyk dot. całego magazynu public override void ShowStatistics() { Console.Clear(); Console.SetWindowSize(Math.Min(100, Console.LargestWindowWidth), Math.Min(55, Console.LargestWindowHeight)); MainMenu.drawLogo(); Console.Write("\n\n\n"); MainMenu.textCentering("Statystyki magazynu: \n\n"); Console.WriteLine($" Liczba grup przedmiotów: {Mock.ItemList.Count()}\n"); int allItemsSum = 0; List <int> allItemsInOneGroup = new List <int>(); List <double> groupCostPer1 = new List <double>(); List <double> groupCost = new List <double>(); int allGoodItemsSum = 0; int allBadItemsSum = 0; for (int i = 0; i < Mock.ItemList.Count(); i++) { allItemsSum += Convert.ToInt32(Mock.ItemList[i].Number); allItemsInOneGroup.Add(Convert.ToInt32(Mock.ItemList[i].Number)); groupCostPer1.Add(Convert.ToDouble(Convert.ToDouble(Mock.ItemList[i].PaidPrice) / Convert.ToDouble(Mock.ItemList[i].Number))); groupCost.Add(Convert.ToDouble(Mock.ItemList[i].PaidPrice)); if (Mock.ItemList[i].Condition == "Sprawne") { allGoodItemsSum += Convert.ToInt32(Mock.ItemList[i].Number); } else if (Mock.ItemList[i].Condition == "Niesprawne") { allBadItemsSum += Convert.ToInt32(Mock.ItemList[i].Number); } } Console.WriteLine($" Całkowita liczba przedmiotów: {allItemsSum}\n"); int indexOfMaxVal = allItemsInOneGroup.FindIndex(x => x == allItemsInOneGroup.Max()); int indexOfMinVal = allItemsInOneGroup.FindIndex(x => x == allItemsInOneGroup.Min()); if (Mock.ItemList.Exists(x => x.ID == 1)) { Console.WriteLine($" Największa grupa przedmiotów: {Mock.ItemList[indexOfMaxVal].Name}; liczba: {allItemsInOneGroup.Max()}\n"); Console.WriteLine($" Najmniejsza grupa przedmiotów: {Mock.ItemList[indexOfMinVal].Name}; liczba: {allItemsInOneGroup.Min()}\n"); } else { Console.WriteLine($" Największa grupa przedmiotów: BRAK; liczba: BRAK\n"); Console.WriteLine($" Najmniejsza grupa przedmiotów: BRAK; liczba: BRAK\n"); } Console.WriteLine($" Liczba sprawnych przedmiotów: {allGoodItemsSum}\n"); Console.WriteLine($" Liczba niesprawnych przedmiotów: {allBadItemsSum}\n"); if (Mock.ItemList.Exists(x => x.ID == 1)) { Console.WriteLine($" Procent sprawnych przedmiotów: {Math.Round(((allGoodItemsSum / (double)(allItemsSum)) * 100) * 10) / 10}%\n"); } else { Console.WriteLine($" Procent sprawnych przedmiotów: BRAK DANYCH\n"); } int indexOfMaxCostPer1 = groupCostPer1.FindIndex(x => x == groupCostPer1.Max()); int indexOfMinCostPer1 = groupCostPer1.FindIndex(x => x == groupCostPer1.Min()); int indexOfMaxCost = groupCost.FindIndex(x => x == groupCost.Max()); int indexOfMinCost = groupCost.FindIndex(x => x == groupCost.Min()); if (Mock.ItemList.Exists(x => x.ID == 1)) { Console.WriteLine($" Grupa najdroższa na sztuce: {Mock.ItemList[indexOfMaxCostPer1].Name}; koszt: {Math.Round((groupCostPer1.Max() * 100)) / 100}zł/szt.\n"); Console.WriteLine($" Grupa najtańsza na sztuce: {Mock.ItemList[indexOfMinCostPer1].Name}; koszt: {Math.Round((groupCostPer1.Min() * 100)) / 100}zł/szt.\n"); Console.WriteLine($" Grupa najdroższa w ogóle: {Mock.ItemList[indexOfMaxCost].Name}; koszt: {Math.Round((groupCost.Max() * 100)) / 100}zł\n"); Console.WriteLine($" Grupa najtańsza w ogóle: {Mock.ItemList[indexOfMinCost].Name}; koszt: {Math.Round((groupCost.Min() * 100)) / 100}zł\n"); } else { Console.WriteLine($" Grupa najdroższa na sztuce: BRAK; koszt: BRAK\n"); Console.WriteLine($" Grupa najtańsza na sztuce: BRAK; koszt: BRAK\n"); Console.WriteLine($" Grupa najdroższa w ogóle: BRAK; koszt: BRAK\n"); Console.WriteLine($" Grupa najtańsza w ogóle: BRAK; koszt: BRAK\n"); } Console.WriteLine($" Saldo konta: {Math.Round((Program.cash * 100)) / 100}zł\n"); Console.WriteLine($" Suma wydatków: {Math.Round((Convert.ToDouble(Program.groupCostSum) * 100)) / 100}zł\n"); Console.WriteLine($" Suma wpływów: {Math.Round(((Convert.ToDouble(Program.cash) + Convert.ToDouble(Program.groupCostSum)) * 100)) / 100}zł\n"); MainMenu.textCentering("\n\n"); MainMenu.textCentering("1 - Wróć do menu głównego\n"); MainMenu.textCentering("\n\n\n\n"); MainMenu.textToRight("Zalogowany magazynier:\n"); MainMenu.textToRight(Program.whoIsLogged); MainMenu.textCentering("\n"); manageStatistics(); }
// ustawienie rozmiaru okna, wyświetlenie na ekranie wszystkich danych zawartych w Mock public override void EnterContent() { Console.Clear(); Console.SetWindowSize(Math.Min(100, Console.LargestWindowWidth), Math.Min(55, Console.LargestWindowHeight)); MainMenu.drawLogo(); Console.Write("\n\n\n"); if (File.ReadLines(Program.path[0]).Count() != 0) { foreach (Mock item in Mock.ItemList) { string sumPaidFor1; int number = Convert.ToInt32(item.Number); if (number != 0) { sumPaidFor1 = Convert.ToString(Convert.ToDouble(item.PaidPrice) / number); } else { sumPaidFor1 = "Niezdefiniowano"; } Console.WriteLine($" ID: {item.ID}"); Console.WriteLine($" Nazwa: {item.Name}"); Console.WriteLine($" Typ: {item.Type}"); Console.Write(" Sztuk: "); if (number <= 3) { Console.ForegroundColor = ConsoleColor.Red; } else if (number <= 15) { Console.ForegroundColor = ConsoleColor.Yellow; } else { Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine($"{item.Number}"); Console.ForegroundColor = Program.defaultFontColor; Console.WriteLine($" W sumie zapłacono: {Math.Round((Convert.ToDouble(item.PaidPrice) * 100)) / 100}zł"); if (number != 0) { Console.WriteLine($" Cena za sztukę: {Math.Round((Convert.ToDouble(sumPaidFor1) * 100)) / 100}zł"); } else { Console.WriteLine($" Cena za sztukę: {sumPaidFor1}"); } Console.Write(" Stan: "); if (item.Condition == "Sprawne") { Console.ForegroundColor = ConsoleColor.Green; } else if (item.Condition == "Niesprawne") { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine($"{item.Condition}"); Console.ForegroundColor = Program.defaultFontColor; Console.WriteLine("\n"); } } else { MainMenu.textCentering("Magazyn jest pusty!\n\n\n\n"); } MainMenu.textCentering("1 - Dodaj grupę przedmiotów\n\n"); MainMenu.textCentering("2 - Usuń grupę przedmiotów \n\n"); MainMenu.textCentering(" 3 - Dodaj/usuń przedmioty z grupy\n\n"); MainMenu.textCentering(" 4 - Zmień nazwę grupy przedmiotów\n\n"); MainMenu.textCentering(" 5 - Zmień stan grupy przedmiotów\n\n"); MainMenu.textCentering("6 - Wróć do menu głównego \n"); MainMenu.textCentering("\n\n\n\n"); MainMenu.textToRight("Zalogowany magazynier:\n"); MainMenu.textToRight(Program.whoIsLogged); MainMenu.textCentering("\n"); manageItems(); }