public bool change() { // Console.WriteLine(",\n "); for (int a = 0; a < allDetailedCourses.Count; a++) { // Console.Write(allDetailedCourses[a].course.courseCode + ", "); } // Console.WriteLine(",\n "); Random rnd = new Random(); for (int a = 0; a < allDetailedCourses.Count; a++) // randomly generate array of ncoins { int num1 = rnd.Next(0, allDetailedCourses.Count); int num2 = rnd.Next(0, allDetailedCourses.Count); DetailedCourse ptr = allDetailedCourses[num1]; allDetailedCourses[num1] = allDetailedCourses[num2]; allDetailedCourses[num2] = ptr; // Console.WriteLine (rnd.Next(0, dummt.Count)+", "); } for (int a = 0; a < allDetailedCourses.Count; a++) { // Console.Write(allDetailedCourses[a].course.courseCode + ", "); } return(true); }
public void printRemainingCourses() { for (int a = 0; a < allDetailedCourses.Count; a++) { if (allDetailedCourses[a].remainingC_Hours != 0) { DetailedCourse c1 = allDetailedCourses[a]; Console.WriteLine(c1.course.courseName + " (" + c1.course.section + ") = {" + c1.monday + ", " + c1.tuesday + ", " + c1.wednesday + ", " + c1.thursday + ", " + c1.friday + "} "); } } }
public void Test27DetailedCourse() { DetailedCourse c1 = new DetailedCourse(); c1.course = new Course(); Course c2 = c1.course; c1.monday = c1.monday; c1.thursday = c1.thursday; c1.tuesday = c1.tuesday; c1.wednesday = c1.wednesday; c1.friday = c1.friday; c1.remainingC_Hours = c1.remainingC_Hours; }
public bool isTeacherClash(int position, DetailedCourse temp, String[,] dayArray) { for (int c = 1; c < rooms + 1; c++) { if (dayArray[c, position] != "null") { Course c1 = db.getCourse(dayArray[c, position]); if (temp.course.teacher == c1.teacher) { return(true); } } } return(false); }
public bool isStudentClash(int position, DetailedCourse temp, String[,] dayArray) { for (int c = 1; c < rooms + 1; c++) { if (dayArray[c, position] != "null") { List <Student> c1 = db.getStudentsClash(temp.course.courseCode, dayArray[c, position]); if (c1.Count > 0) { return(true); } } } return(false); }
public bool traverseSlots(DetailedCourse temp, String[,] dayArray) { for (int a = 1; a < rooms + 1; a++) // traversing rooms { for (int b = 1; b < timeHours + 1; b++) // traversing timeslots { // pick empty rooms and fits a clash free class if (dayArray[a, b] == "null") // if empty (no class set on this slot) { if (isTeacherClash(b, temp, dayArray) == false && isStudentClash(b, temp, dayArray) == false) // b=col to check clashes { row = a; col = b; return(true); } } } } return(false); }
public bool getDayBool(int num, DetailedCourse detailedCourse) { if (num == 1) { return(detailedCourse.monday); } else if (num == 2) { return(detailedCourse.tuesday); } else if (num == 3) { return(detailedCourse.wednesday); } else if (num == 4) { return(detailedCourse.thursday); } else { return(detailedCourse.friday); } }
public List <DetailedCourse> getAllCoursesWithoutLabs(String dummyString = "null") { if (dummyString != "null") { connectionString += dummyString; } SqlConnection con = null; List <DetailedCourse> allCourses = new List <DetailedCourse>(); SqlCommand cmd = null; try { con = new SqlConnection(connectionString); cmd = new SqlCommand("SELECT * FROM " + courseTable + " where cHours>=3", con); cmd.Connection.Open(); SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { Course s1 = new Course(); s1.courseCode = (String)sdr["courseCode"]; s1.courseCode = s1.courseCode.Replace(" ", String.Empty); s1.courseName = (String)sdr["courseName"]; s1.courseName = s1.courseName.Replace(" ", String.Empty); s1.timeTableName = (String)sdr["timeTableName"]; s1.timeTableName = s1.timeTableName.Replace(" ", String.Empty); s1.section = (String)sdr["section"]; s1.section = s1.section.Replace(" ", String.Empty); s1.regStudents = (int)sdr["regStudents"]; s1.creditHours = (int)sdr["cHours"]; s1.teacher = (String)sdr["teacher"]; s1.teacher = s1.teacher.Replace(" ", String.Empty); s1.semester = (int)sdr["sem"]; s1.pre = (String)sdr["pre"]; s1.pre = s1.pre.Replace(" ", String.Empty); // Console.WriteLine(s1.courseCode+", "+ s1.courseName + ", " + s1.timeTableName + ", " + s1.section + ", " + s1.regStudents + ", " + s1.creditHours + ", " + s1.teacher + ", " + s1.section + ", " + s1.semester); // Console.Write(s1.courseCode+", "); DetailedCourse temp = new DetailedCourse(); temp.course = s1; temp.remainingC_Hours = s1.creditHours; allCourses.Add(temp); } cmd.Connection.Close(); } catch (Exception e) { cmd.Connection.Close(); Console.WriteLine("Getting all courses error"); Console.WriteLine(e.ToString()); return(null); } // Console.WriteLine("Courses returned"); return(allCourses); }