Пример #1
0
        public void Track(T user)
        {
            bool flag = true;

            while (flag)
            {
                Console.ResetColor();
                Console.Clear();
                Console.WriteLine("Choose your activity :");
                Console.WriteLine("1) Reading \n2) Ecercising \n3) Working\n4) Other\n5) Back to main menu");


                bool success = int.TryParse(Console.ReadLine(), out int choice);
                if (!success)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Wrong input! Please choose one of the available options!");
                }
                else if (choice == 1)
                {
                    reading.ReadingActive();
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    Console.WriteLine("When you are done, and want to stop counting the time, press Enter");
                    string finish = Console.ReadLine();
                    if (finish == "")
                    {
                        stopwatch.Stop();
                        TimeSpan countedTime   = stopwatch.Elapsed;
                        double   timeInSeconds = Convert.ToDouble(countedTime.TotalSeconds);
                        user.ReadingTime += timeInSeconds / 60;
                        Console.WriteLine($"Time spent reading: {Math.Round(timeInSeconds / 60, 2)} minutes");
                        Console.WriteLine("Press anything to continue...");
                        Console.ReadKey();
                        flag = false;
                    }
                }

                else if (choice == 2)
                {
                    exercising.ExercisingActive();
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    Console.WriteLine("When you are done, and want to stop counting the time, press Enter");
                    string finish = Console.ReadLine();
                    if (finish == "")
                    {
                        stopwatch.Stop();
                        TimeSpan countedTime   = stopwatch.Elapsed;
                        double   timeInSeconds = Convert.ToDouble(countedTime.TotalSeconds);
                        user.ReadingTime += timeInSeconds / 60;
                        Console.WriteLine($"Time spent exercising : {Math.Round(timeInSeconds / 60, 2)} minutes");
                        Console.WriteLine("Press anything to continue...");
                        Console.ReadKey();
                        flag = false;
                    }
                }

                else if (choice == 3)
                {
                    working.WorkingActive(user);
                    flag = false;
                }

                else if (choice == 4)
                {
                    otherHobbies.OtheHobbiesActive(user);
                    flag = false;
                }
                else if (choice == 5)
                {
                    break;
                }
            }
        }