Esempio n. 1
0
        // 강의 조회 화면, mode 매개변수를 통해 수강 신청, 관심 과목 담기 등에서 쓰일 수 있음
        public void LectureLookup(int mode)
        {
            int choice = ConstNumber.ESC;
            // 검색된 튜플 인덱스를 담는 리스트
            List <int> searchedTuple;

            while (true)
            {
                // 검색 조건 입력 받음
                string[] conditions = outputProcessor.LectureListHeaderScreen();
                // 검색 도중 중지되었다면 나감
                if (conditions == null)
                {
                    return;
                }
                Console.SetCursorPosition(0, 4);

                // 검색 조건에 맞는 강의 목록 출력
                // 수강 신청에서의 강의 조회
                if (mode == ConstNumber.REAL_CHOICE)
                {
                    searchedTuple = outputProcessor.LectureListScreen(allLectureData, conditions, student.appliedSubjects, 167);
                }
                // 관심과목 담기에서의 강의 조회
                else
                {
                    searchedTuple = outputProcessor.LectureListScreen(allLectureData, conditions, student.containedSubjects, 167);
                }

                // 검색된 강의가 없다면
                if (searchedTuple.Count == 0)
                {
                    outputProcessor.PressAnyKey("검색된 강의가 없습니다.");
                }
                else
                {
                    // 사용자에 의한 강의 선택
                    choice = outputProcessor.LectureChoice(searchedTuple.Count);
                }

                if (choice == ConstNumber.ESC)
                {
                    return;
                }
                else
                {
                    // 현재 선택된 강의의 학점
                    int presentCredit = allLectureData.ReturnCredit(searchedTuple[choice]);
                    // 수강신청, 관심과목 담기를 달리 함
                    // 수강 신청
                    if (mode == ConstNumber.REAL_CHOICE)
                    {
                        if (outputProcessor.YesOrNo("선택한 강의를 신청하시겠습니까?") == 1)
                        {
                            // 동일과목이 이미 수강신청되어 있는지 학수번호를 확인한다
                            if (CheckLectureNo(searchedTuple[choice]))
                            {
                                // 신청학점이 최대학점을 초과하지 않는지 확인한다
                                if ((student.appliedCredit + presentCredit) <= ConstNumber.MAX_APPLIED)
                                {
                                    // 신청 강의가 이미 신청된 강의들과 시간이 겹치지 않는지 확인하고 그렇지 않다면 추가한다
                                    if (AddTimeTable(allLectureData, student.timeTable, searchedTuple[choice]))
                                    {
                                        student.AddAppliedSubject(searchedTuple[choice], presentCredit);
                                    }
                                    else
                                    {
                                        outputProcessor.PressAnyKey("다른 강의와 시간이 겹칩니다.");
                                    }
                                }
                                else
                                {
                                    outputProcessor.PressAnyKey("최대 신청 가능 학점을 초과하였습니다.");
                                }
                            }
                            else
                            {
                                outputProcessor.PressAnyKey("이미 동일 과목이 신청되었습니다.");
                            }
                        }
                    }
                    // 관심과목 담기
                    else
                    {
                        if (outputProcessor.YesOrNo("선택한 강의를 담으시겠습니까?") == 1)
                        {
                            // 관심과목 담기 학점이 최대 학점을 초과하지 않는지 확인한다
                            if ((student.containedCredit + presentCredit) <= ConstNumber.MAX_INTERESTED)
                            {
                                student.AddContainedSubject(searchedTuple[choice], presentCredit);
                            }
                            else
                            {
                                outputProcessor.PressAnyKey("최대 담을 수 있는 학점을 초과하였습니다.");
                            }
                        }
                    }
                    if (searchedTuple.Count == 0)
                    {
                        return;
                    }
                }
            }
        }