static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Magenta;

            Console.WriteLine(@" 
                    _   _  _    __ _____   _   __     __
                   | | | || |  / //  _  \ | |  \ \   / /
                   | | | || |_/ / | | | | | |   \ \_/ /
                   | | | ||    /  | | | | | |     | |
                   | |_| || |\ \  | |_| | | |____ | |
                   \_____/\_| \_\ \_____/ \______||_|
                                          ");
            Console.ResetColor();
            ProgramManagemant         programManagemant         = new ProgramManagemant();
            MakerHW                   makerHW                   = new MakerHW();
            CommandsWorkingWithHWList commandsWorkingWithHWList = new CommandsWorkingWithHWList();

            Console.WriteLine(programManagemant.ShowMenu());  // Shows the menu of commands on the console.
            User user = new User("start");

            while (!programManagemant.FinishApp(user.UserResponse))  //It lasts until the end "konec" is written
            {
                user.UserResponse = Console.ReadLine();

                try
                {
                    user.ChoseNumberUserResponse = int.Parse(user.UserResponse);
                    commandsWorkingWithHWList.ChangeHWExist(true);
                }
                catch
                {
                    Console.WriteLine("Tenhle příkaz není k dispozici. Zkusit zadat znovu:");
                    commandsWorkingWithHWList.ChangeHWExist(false);
                }

                while (commandsWorkingWithHWList.HWExist)
                {
                    if (user.ChoseNumberUserResponse > 7)
                    {
                        Console.WriteLine("Tenhle příkaz není k dispozici. Zkusit zadat znovu:");
                        commandsWorkingWithHWList.ChangeHWExist(false);
                    }
                    else
                    {
                        switch (user.ChoseNumberUserResponse)  // The console reads the number and selects the case to which it redirects the user
                        {
                        case 1:                                //Here you set and add homework.
                            commandsWorkingWithHWList.Bool();
                            Console.WriteLine(new string('-', 45));
                            Console.WriteLine("Zadejte jeden z předmětů:");
                            makerHW.MakeNewHW();
                            HomeWork homeWork = new HomeWork(makerHW.Subject, makerHW.Topic, makerHW.Deadline, makerHW.Marking, makerHW.ID);
                            commandsWorkingWithHWList.AddHomeWork(homeWork);
                            Console.WriteLine(homeWork);
                            commandsWorkingWithHWList.ChangeHWExist(false);
                            break;

                        case 2:                                                     //Here, the status of the task changes to complete
                            commandsWorkingWithHWList.DoCase2AndFinishHWWithControls();
                            break;

                        case 3:                                                   //This is where homework is removed
                            commandsWorkingWithHWList.DoCase3AndRemoveHWWithControls();

                            break;

                        case 4:                                               //Here is a list of homeworks
                            commandsWorkingWithHWList.DoCase4AndShowSeparateListHWWithControls();
                            break;

                        case 5:                                               //here you can change the properties of the homework

                            commandsWorkingWithHWList.DoCase5AndChangeHWWithControls();
                            break;

                        case 6:                                             //Here you can search for homework on user response
                            commandsWorkingWithHWList.DoCase6AndSearchingInHWWithControls();
                            break;

                        case 7:                                         //end of application
                            programManagemant.FinishApp();
                            commandsWorkingWithHWList.ChangeHWExist(false);
                            break;
                        }
                    }
                }
            }
            Environment.Exit(0);
        }
예제 #2
0
        public void ChangeHomeWork()
        {
            HomeWork = null;
            MakerHW makerHW = new MakerHW();

            foreach (var homeWork in listHomeWork)
            {
                if (homeWork.ID == UserID)
                {
                    Console.WriteLine(
                        @"Chcete změnit:
                                   1. ID        4. Čas
                                   2. Předmět   5. Bodování
                                   3. Téma      ");
                    bool b;
                    int  choseNumberUserResponse = 0;
                    try
                    {
                        choseNumberUserResponse = int.Parse(Console.ReadLine());
                        b = true;
                    }
                    catch
                    {
                        Console.WriteLine("Tenhle příkaz není k dispozici. Zkusit zadat znovu:");
                        b = false;
                    }
                    while (b)
                    {
                        switch (choseNumberUserResponse)
                        {
                        case 1:
                            makerHW.ChangeBool1(false);
                            Console.WriteLine("Zadejte nové ID:");
                            string response;
                            while (!makerHW.Bool1)
                            {
                                response = Console.ReadLine();
                                makerHW.GetControlOfID(response);
                            }

                            homeWork.ChangeID(makerHW.ID);
                            b = false;
                            break;

                        case 2:
                            makerHW.ChangeBool1(false);
                            Console.WriteLine("Zadejte nový předmět:");
                            makerHW.ShowSchoolSubjects();
                            while (!makerHW.Bool1)
                            {
                                response = Console.ReadLine();
                                makerHW.GetControlOfSubject(response);
                            }

                            homeWork.ChangeSubject(makerHW.Subject);
                            b = false;

                            break;

                        case 3:
                            makerHW.ChangeBool1(true);
                            Console.WriteLine("Zadejte nové téma:");
                            while (makerHW.Bool1)
                            {
                                response = Console.ReadLine();
                                makerHW.GetControlOfTopic(response);
                            }
                            homeWork.ChangeTopic(makerHW.Topic);
                            b = false;

                            break;

                        case 4:
                            Console.WriteLine("Zadej nový čas:");
                            while (!makerHW.Bool1)
                            {
                                response = Console.ReadLine();
                                makerHW.GetControlOfDeadLine(response);
                            }
                            homeWork.ChangeDeadline(makerHW.Deadline);
                            break;

                        case 5:
                            makerHW.ChangeBool1(true);
                            Console.WriteLine("Zadejte nové bodování:");

                            while (makerHW.Bool1)
                            {
                                response = Console.ReadLine();
                                makerHW.GetControlOfMarking(response);
                            }
                            homeWork.ChangeMarking(makerHW.Marking);
                            b = false;

                            break;
                        }
                    }
                    HomeWork = homeWork;
                }
            }
            try
            {
                FindNull(WriteHomeWork(HomeWork));
                Console.WriteLine(WriteHomeWork(HomeWork));
                Bool1 = true;
            }
            catch
            {
                Console.WriteLine("Nebylo zadáno správné ID. Zkuste znovu:");
                Bool1 = false;
            }
        }