Exemplo n.º 1
0
        public bool test2() //search database with nothing entered (all courses in database will be returned); course ID's are 0 through 760
        {
            Search     search = Search.Create("course_dictionary.txt");
            CourseInfo DB     = CourseInfo.Create();

            search.options.clear();
            search.options.firstNameProfessor = "";
            search.options.lastNameProfessor  = "";
            search.searchForQuery("");
            search.advancedSearchFilter();

            int i = 0;

            foreach (var course in search.lastSearchResults.getCourses())
            {
                if (i++ != course.getCourseID())
                {
                    return(false);
                }
            }
            if (i != DB.getNumCourses())
            {
                return(false);
            }
            if (i != 761)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        // displays an info box containing information about a course
        string getCalendarPopupString(int id)
        {
            // Gets all courses with same course code:
            List <int> ids = new List <int>();

            for (int i = 0; i < DB.getNumCourses(); i++)
            {
                if (DB.getCourseCode(i) == DB.getCourseCode(id))
                {
                    ids.Add(i);
                }
            }

            string val = DB.getCourseCode(ids[0]) + "\n";

            val += DB.getLongName(ids[0]) + "\n";
            val += "with " + DB.getProf(ids[0]).first + " " + DB.getProf(ids[0]).last + "\n\n";

            int credits = 0;

            foreach (int course_id in ids)
            {
                val     += DB.getCourse(course_id).getTimeString().Item1 + " to " + DB.getCourse(course_id).getTimeString().Item2;
                val     += " on " + getDays(DB.getCourse(course_id)) + " in " + DB.getBuilding(course_id) + " " + DB.getRoom(course_id) + "\n";
                credits += DB.getCredits(course_id);
            }

            val += "\n" + credits.ToString() + " total credits\n";
            val += DB.getEnrollment(ids[0]).ToString() + " seats taken out of " + DB.getCapacity(ids[0]).ToString() + "\n";
            return(val);
        }
Exemplo n.º 3
0
        //adds a course to the candidate schedule based on course object,
        //along with any courses with the same course code
        public void addCourse(Course c)
        {
            if (schedule.Contains(c))
            {
                return;
            }
            creditCount += c.getCredits();
            schedule.Add(c);

            int id = c.getCourseID();

            //adds courses with same name recursivly
            if (id < DB.getNumCourses() - 1 && DB.getCourseCode(id + 1) == DB.getCourseCode(id))
            {
                addCourse(DB.getCourse(id + 1));
            }
            else if (id > 0 && DB.getCourseCode(id - 1) == DB.getCourseCode(id))
            {
                addCourse(DB.getCourse(id - 1));
            }

            addToCalendar(id);
        }