static void max() { header(); Console.WriteLine("***************"); Console.WriteLine("PRODUCTO MAXIMO"); Console.WriteLine("***************"); MP___don_chapo.database.product max_product = new MP___don_chapo.database.product(); foreach (MP___don_chapo.database.product product in db) { if (max_product is MP___don_chapo.database.product && product is MP___don_chapo.database.product) { if (product.count > max_product.count && !product.removed) { max_product = product; } } } Console.WriteLine("ID: {0} : COUNT: {1}", max_product.id, max_product.count); }
static void Main(string[] args) { header(); // CREATE PRODUCT int[] stocks = new int[db.Length]; for (int i = 0; i < db.Length; ++i) { Console.SetCursorPosition(0, Console.CursorTop); Console.Write("Generando inventario {0}/{1}...", i + 1, db.Length); int stock = 0; while (true) { stock = random.Next(0, 100); if (!stocks.Contains(stock)) { stocks[i] = stock; break; } } db[i] = new MP___don_chapo.database.product(i, stock); } Console.ReadKey(); while (true) { header(); Console.WriteLine("¿Qué te gustaría que haga hoy? (? : ayuda )"); Console.ForegroundColor = ConsoleColor.Blue; string answer = Console.ReadLine().ToLower(); switch (answer) { case "?": ayuda(); break; case "salir": return; case "lista": lista(); break; case "max": max(); break; case "repoblar": repoblar(); break; case "eliminar": eliminar(); break; default: error("No entendí del todo, intente de nuevo..."); Console.ReadKey(); continue; } Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n\nPulse cualquier tecla para continuar..."); Console.ReadKey(); Console.Clear(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("¿Qué te gustaría que haga ahora? (? : ayuda )"); } }