Example #1
0
        private static void Menu(Months month)
        {
            int     userInput = 0;
            Boolean quit      = false;

            PrintMainMenu();
            while (!quit)
            {
                try
                {
                    userInput = Convert.ToInt32(Console.ReadLine());
                }
                catch
                {
                    Console.WriteLine("Please enter a number");
                    continue;
                }

                switch (userInput)
                {
                case 0:
                    quit = true;
                    break;

                case 1:
                    month.PrintAllTransactions();
                    break;

                case 2:
                    Console.Write("Enter category: ");
                    string category = Console.ReadLine();
                    month.CategorizedTransactions(category);
                    break;

                case 3:
                    Console.Write("Enter first category: ");
                    string caterogy1 = Console.ReadLine();
                    Console.Write("Enter second category: ");
                    string caterogy2 = Console.ReadLine();
                    month.CategorizedTransactions(caterogy1, caterogy2);
                    break;

                case 4:
                    Console.WriteLine("-----Top-5-Categories-----");
                    foreach (var item in Stats.TopCategory(month.Trancastions))
                    {
                        Console.WriteLine(item.Key + " " + item.Value);
                    }
                    Console.WriteLine("--------------------------");
                    break;

                case 5:
                    Console.WriteLine("-----Top-5-Places-----");
                    foreach (var item in Stats.TopPlace(month.Trancastions))
                    {
                        Console.WriteLine(item.Key + " " + item.Value);
                    }
                    Console.WriteLine("----------------------");
                    break;

                case 6:
                    Console.WriteLine("Top Transaction: " + Stats.TopTransaction(month.Trancastions));
                    break;

                case 7:
                    Console.WriteLine("-----Top-5-Visited-----");
                    foreach (var item in Stats.TopVisited(month.Trancastions))
                    {
                        Console.WriteLine(item.Key + " " + item.Value);
                    }
                    Console.WriteLine("-----------------------");
                    break;

                case 8:
                    Console.WriteLine("-----Comparing-----");
                    foreach (var item in Stats.CompareToPreviousMonth(months))
                    {
                        Console.Write(item.Key + " " + item.Value + " ");
                    }
                    Console.WriteLine("-------------------");

                    break;

                case 9:
                    PrintMainMenu();
                    break;

                default:
                    Console.WriteLine("please enter number between 0 and 9");
                    break;
                }
            }
        }