Ejemplo n.º 1
0
        // 수강신청-관심과목 검색
        public void InterestedSubjectLookup(int mode)
        {
            int choice       = ConstNumber.ESC;
            int screenHeight = 30;

            // 담긴 관심과목이 없다면
            if (student.containedSubjects.Count == 0)
            {
                outputProcessor.PressAnyKey("담겨진 관심과목이 없습니다.");
                return;
            }
            else
            {
                while (true)
                {
                    Console.Clear();
                    Console.Write("\n\n\n\n");
                    Console.SetWindowSize(183, screenHeight);
                    // 담긴 과목 리스트 출력
                    outputProcessor.PrintLectureList(allLectureData, student.containedSubjects);

                    // 강의 선택
                    choice = outputProcessor.LectureChoice(student.containedSubjects.Count);

                    if (choice == ConstNumber.ESC)
                    {
                        return;
                    }
                    // 선택한 과목의 학점
                    int presentCredit = allLectureData.ReturnCredit(student.containedSubjects[choice]);

                    // 관심과목으로 수강신청일 때
                    if (mode == ConstNumber.REAL_CHOICE)
                    {
                        if (outputProcessor.YesOrNo("선택한 강의를 신청하시겠습니까?") == 1)
                        {
                            // 동일과목이 이미 수강신청되어 있는지 학수번호를 확인한다
                            if (CheckLectureNo(student.containedSubjects[choice]))
                            {
                                // 신청학점이 최대학점을 초과하지 않는지 확인한다
                                if ((student.appliedCredit + presentCredit) <= ConstNumber.MAX_APPLIED)
                                {
                                    // 신청 강의가 이미 신청된 강의들과 시간이 겹치지 않는지 확인하고 그렇지 않다면 추가한다
                                    if (AddTimeTable(allLectureData, student.timeTable, student.containedSubjects[choice]))
                                    {
                                        student.AddAppliedSubject(student.containedSubjects[choice], presentCredit);
                                        // 관심과목에서 삭제
                                        student.DeleteContainedSubject(student.containedSubjects[choice], presentCredit);
                                    }
                                    else
                                    {
                                        outputProcessor.PressAnyKey("다른 강의와 시간이 겹칩니다.");
                                    }
                                }
                                else
                                {
                                    outputProcessor.PressAnyKey("최대 신청 가능 학점을 초과하였습니다.");
                                }
                            }
                            else
                            {
                                outputProcessor.PressAnyKey("이미 동일 과목이 신청되었습니다.");
                            }
                        }
                        // 더 이상 담긴 관심과목이 없다면
                        if (student.containedSubjects.Count == 0)
                        {
                            return;
                        }
                    }
                    else
                    {
                        if (outputProcessor.YesOrNo("관심과목에서 삭제하시겠습니까?") == 1)
                        {
                            // 선택된 관심과목을 삭제
                            student.DeleteContainedSubject(student.containedSubjects[choice], presentCredit);
                            // 더 이상 담긴 관심과목이 없다면
                            if (student.containedSubjects.Count == 0)
                            {
                                return;
                            }
                        }
                    }
                }
            }
        }