コード例 #1
0
        /// <summary>
        /// метод запускает меню предмета
        /// </summary>
        /// <param name="student"></param>
        public static void StartSubjectMenu(IJournalMarks journalMarks, IStudent student, ISubject subject, int index)
        {
            Clear();//очищаем консоль
            do
            {
                WriteLine("       Subject menu:");
                WriteLine((int)SubjectMenu.ShowMarks + " - Show all  marks,");
                WriteLine((int)SubjectMenu.AddMark + " - Add mark,");
                WriteLine((int)SubjectMenu.CorrectMark + " - Correct mark,");
                WriteLine((int)SubjectMenu.DelMark + " - Delete mark,");
                WriteLine((int)SubjectMenu.BackMenu + " - Back");

                string choice = null;
                int    answer = 0;
                do
                {
                    Write("Your choice: ");
                    choice = ReadLine();
                } while (!int.TryParse(choice, out answer));
                WriteLine("--------------------------------");

                switch ((SubjectMenu)answer)
                {
                case SubjectMenu.ShowMarks:
                    ClassSubjectMenu.ShowMarks(subject);
                    break;

                case SubjectMenu.AddMark:
                    ClassSubjectMenu.AddMark(student, subject, index);
                    break;

                case SubjectMenu.CorrectMark:
                    ClassSubjectMenu.CorrectMark(subject);
                    break;

                case SubjectMenu.DelMark:
                    ClassSubjectMenu.DelMark(subject);
                    break;

                case SubjectMenu.BackMenu:
                    StudentMenu.StartStudentMenu(journalMarks, student);
                    break;

                default:
                    WriteLine("Error iteam menu...");
                    break;
                }
                WriteLine("Done!");
                ReadKey(); //пауза
                Clear();   //очистка консоли
            } while (true);
        }
コード例 #2
0
        /// <summary>
        /// выбрать студента
        /// </summary>
        /// <param name="journalMarks"></param>
        public static void ChoiceStudent(IJournalMarks journalMarks)
        {
            WriteLine(journalMarks);

            string data   = null;
            int    number = 0;

            do
            {
                Write("Choice student: ");
                data = ReadLine();
            } while (!int.TryParse(data, out number) || number <= 0 || number > journalMarks.Count);

            StudentMenu.StartStudentMenu(journalMarks, journalMarks.Students[number - 1]);
        }