Example #1
0
        // Other methods
        public NList Copy()
        {
            if (Length > 0)
            {
                NList tmp = new NList();
                Node tmpCursor;

                tmp.FrontN = (Node) FrontN.Clone();
                tmp.Length = Length;
                tmpCursor = tmp.FrontN;

                while (tmpCursor != null)
                {
                    if (tmpCursor.Next == null)
                    {
                        tmp.BackN = tmpCursor;
                    }

                    tmpCursor = tmpCursor.Next;
                }

                return tmp;
            }

            return new NList();
        }
        private void frmCourse_Load(object sender, EventArgs e)
        {
            txtID.Text        = course.CourseID;
            txtDesc.Text      = course.Description;
            cbxFall.Checked   = course.Fall;
            cbxWinter.Checked = course.Winter;
            cbxSpring.Checked = course.Spring;
            cbxSummer.Checked = course.Summer;

            if (course.Prereqs != null && course.Prereqs.Length > 0)
            {
                NList iter = course.Prereqs;
                for (iter.MoveFront(); iter.Index >= 0; iter.MoveNext())
                {
                    lbxPre.Items.Add(iter);
                }
            }
            else
            {
                lbxPre.Items.Add("None");
            }

            if (course.Coreqs != null && course.Coreqs.Length > 0)
            {
                NList iter = course.Coreqs;
                for (iter.MoveFront(); iter.Index >= 0; iter.MoveNext())
                {
                    lbxCo.Items.Add(iter);
                }
            }
            else
            {
                lbxCo.Items.Add("None");
            }
        }
Example #3
0
 public Course(string id, string desc, byte units, bool f, bool w, bool s, bool u, NList p, NList c)
 {
     CourseID    = id;
     Description = desc;
     Units       = units;
     Fall        = f;
     Winter      = w;
     Spring      = s;
     Summer      = u;
     Prereqs     = p;
     Coreqs      = c;
 }
        private void   cmdGo_Click(object sender, EventArgs e)
        {
            try
            {
                string id      = GetString(txtCourseID);
                string name    = GetString(txtCourseName);
                byte   units   = 0;
                NList  prereqs = new NList();

                if (!Byte.TryParse(GetString(txtCourseUnits), out units))
                {
                    units = 0;
                }

                foreach (object course in lbxPrereqs.Items)
                {
                    prereqs.Append((Course)course);
                }

                Course cs = new Course(id,
                                       name,
                                       units,
                                       cbxFall.Checked,
                                       cbxWinter.Checked,
                                       cbxSpring.Checked,
                                       cbxSummer.Checked,
                                       prereqs,
                                       null);

                mainDB.Add(id, cs);
                mainDB.SaveDB();
                mainDB.PopulateListBox(lbxCList);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Error creating course. {0}", ex.Message));
            }
        }
Example #5
0
        public bool Equals(Object o)
        {
            bool tmp = false;

            if (o is NList)
            {
                NList L    = (NList) o;
                Node  me   = FrontN;
                Node  them = L.FrontN;

                if ((tmp = Length == L.Length)) // Hidden assignment
                {
                    while (tmp && me != null)
                    {
                        tmp  = me.Data == them.Data;
                        me   = me.Next;
                        them = them.Next;
                    }
                }
            }

            return tmp;
        }
Example #6
0
        private void AddCourse(Course course, CourseDB term, ListBox lbx)
        {
            NList        iter = course.Prereqs.Copy();
            AcademicYear ay;
            Course       cs;
            bool         found;

            // Check previous years for prereqs
            for (int i = 0; i < yearIndex; ++i)
            {
                ay = plan[i];

                for (iter.MoveFront(); iter.Index >= 0; iter.MoveNext())
                {
                    cs    = (Course)iter.Get();
                    found = ay.Fall.ContainsKey(cs.CourseID) || ay.Winter.ContainsKey(cs.CourseID) || ay.Spring.ContainsKey(cs.CourseID) || ay.Summer.ContainsKey(cs.CourseID);

                    if (found)
                    {
                        iter.Delete();
                    }
                }
            }

            ay = plan[yearIndex];

            // Check current year for prereqs
            for (iter.MoveFront(); iter.Index >= 0; iter.MoveNext())
            {
                cs = (Course)iter.Get();

                if (term == ay.Winter)
                {
                    found = ay.Fall.ContainsKey(cs.CourseID);
                }
                else if (term == ay.Spring)
                {
                    found = ay.Winter.ContainsKey(cs.CourseID) || ay.Fall.ContainsKey(cs.CourseID);
                }
                else if (term == ay.Summer)
                {
                    found = ay.Spring.ContainsKey(cs.CourseID) || ay.Winter.ContainsKey(cs.CourseID) || ay.Fall.ContainsKey(cs.CourseID);
                }
                else
                {
                    found = false;
                }

                if (found)
                {
                    iter.Delete();
                }
            }

            // Only add the course if it's prerequisites have been satisfied
            if (iter.Length < 1)
            {
                term.Add(course.CourseID, course);
                ay.SaveYear();
                term.PopulateListBox(lbx);
            }
        }