Exemple #1
0
        public bool ChangeSelectedCourse(Course course)
        {
            List <Course> courses = null;
            Student       s       = null;

            foreach (KeyValuePair <Student, List <Course> > item in dic)
            {
                if (item.Key.Equals(stu))
                {
                    courses = item.Value;
                    courses.Remove(course);
                    s = item.Key;
                }
            }
            if (!courses.Contains(course))
            {
                dic[s] = courses;
                InputAndOutput.OutPutSelectedCourse(dic);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        public bool SelectCourse(Course course)
        {
            Student       s       = null;
            List <Course> courses = new List <Course>();

            foreach (KeyValuePair <Student, List <Course> > item in dic)
            {
                if (item.Key.Equals(stu))
                {
                    courses = item.Value;
                    courses.Add(course);
                    s = item.Key;
                }
            }
            if (courses.Count <= 0)
            {
                courses.Add(course);
                dic.Add(stu, courses);
                if (courses.Contains(course))
                {
                    InputAndOutput.OutPutSelectedCourse(dic);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (courses.Contains(course))
                {
                    dic[s] = courses;
                    InputAndOutput.OutPutSelectedCourse(dic);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }