public static void Menu() { Start: Console.Clear(); Console.WriteLine("1. See all averages\n\n2. Delete all averages\n\n3. Delete all averages by ID\n"); switch (Console.ReadLine()) { case "-1": break; case "1": Average.Show(); goto Start; case "2": DeleteAll(); goto Start; case "3": DeleteByID(); goto Start; default: Console.WriteLine("Write a valid value !"); Console.ReadLine(); goto Start; } }
public static void Calculate(Averages average) { string ID = GetID(); float[] values = GetValues(); float averageRes = 0; switch (average) { case Averages.Arithmetic: averageRes = AverageFormulas.Arithmetic(values); break; case Averages.Weighted: averageRes = AverageFormulas.Weighted(values); break; case Averages.Harmonic: averageRes = AverageFormulas.Harmonic(values); break; case Averages.Geometric: averageRes = AverageFormulas.Geometric(values); break; } var Useraverage = new Average(ID, average, averageRes, values, DateTime.Now); averages.Add(Useraverage); Console.Clear(); Show(Useraverage); Console.ReadLine(); }
private static void Show(Average average) { Console.Write($"ID: {average.ID}\nType: {average.type}\nAverage result: {average.average}\nCreation data: {average.creationDate}\nValues: "); for (int i = 0; i < average.values.Length; i++) { Console.Write($"{average.values[i]} "); } Console.WriteLine("\n"); }
private static void Main(string[] args) { Start: Console.Clear(); Console.WriteLine("==========================\nWELLCOME TO MY PROGRAM\n==========================\n"); if (Average.averages.Count == 0) { Console.WriteLine("Select the average you want to calculate or exit writing -1: \n\n1. Arithmetic\n\n2. Weighted\n\n3. Harmonic\n\n4. Geometric\n"); } else { Console.WriteLine("Select the average you want to calculate, exit writing -1 or Manage your averages: \n\n1. Arithmetic\n\n2. Weighted\n\n3. Harmonic\n\n4. Geometric\n\n5. Manage\n"); } string option = Console.ReadLine(); switch (option) { case "1": case "2": case "3": case "4": Average.Calculate((Averages)int.Parse(option)); goto Start; case "5": if (Average.averages.Count == 0) { Console.WriteLine("Write a valid value !"); Console.ReadLine(); goto Start; } else { AverageManage.Menu(); } goto Start; case "-1": break; default: Console.WriteLine("Write a valid value !"); Console.ReadLine(); goto Start; } }