protected void testConflict() { Stack<Class> schedule = new Stack<Class>(); Class firstClass = new Class(); Class secondClass = new Class(); Class thirdClass = new Class(); firstClass.startTime = 1000; firstClass.endTime = 1050; firstClass.days.Add("M"); firstClass.days.Add("W"); firstClass.days.Add("F"); secondClass.startTime = 1000; secondClass.endTime = 1050; secondClass.days.Add("T"); secondClass.days.Add("R"); thirdClass.startTime = 1000; thirdClass.endTime = 1050; thirdClass.days.Add("M"); thirdClass.days.Add("W"); thirdClass.days.Add("F"); schedule.Push(firstClass); schedule.Push(secondClass); schedule.Push(thirdClass); if (noConflict(schedule)) { Response.Write("hello"); } }
protected void CreateCourseStack() { courses = new Stack<Course>(); SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Courses"].ConnectionString); while(lbAdded.Items.Count > 0){ Course currentCourse = new Course(); string item = lbAdded.Items[0].ToString(); string qry = "select * from Schedule where CourseNumber=@number"; SqlCommand cmd = new SqlCommand(qry, conn); cmd.Parameters.AddWithValue("@number", item); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Class currentClass = new Class(); currentClass.CRN = reader["CRN"].ToString(); currentClass.courseNumber = reader["CourseNumber"].ToString(); currentClass.sectionNumber = reader["SectionNumber"].ToString(); currentClass.startTime = Convert.ToInt16(reader["StartTime"]); currentClass.endTime = Convert.ToInt16(reader["EndTime"]); string days = reader["Days"].ToString(); for (int i = 0; i < days.Length; i++) { currentClass.days.Add(days.Substring(i,1)); } currentCourse.Classes.Push(currentClass); } courses.Push(currentCourse); lbAdded.Items.RemoveAt(0); conn.Close(); } }