public void AllSmartSchedules() { Console.WriteLine("Enter class numbers seperated by a comma"); string classR = Console.ReadLine(); string[] classReq = classR.Split(','); ScheduleList tsl = new ScheduleList(); scheduleOptions = GetAllSchedules(classReq); if (scheduleOptions.Count > 0) { Console.WriteLine("scheduleing sucessfull"); Console.WriteLine(String.Format("There are {0} possable schedules for the selected cources", scheduleOptions.Count.ToString())); } else { Console.WriteLine("Unable to schedule classes"); } }
public void AllSmartSchedulesWithError() { Console.WriteLine("Enter class numbers seperated by a comma"); string classR = Console.ReadLine(); string[] classReq = classR.Split(','); Console.WriteLine("What is the max number of classes that can fail and still be a vaild schedule?"); int maxError = int.Parse(Console.ReadLine()); ScheduleList tsl = new ScheduleList(); scheduleOptions = GetAllSchedulesEx(classReq, maxError); if (scheduleOptions.Count > 0) { Console.WriteLine("scheduleing sucessfull"); Console.WriteLine(String.Format("There are {0} possable schedules for the selected cources", scheduleOptions.Count.ToString())); } else { Console.WriteLine("Unable to schedule classes"); } }
private void SomeScheduleWorks(ScheduleList tsl, string[] rlist, int rindex, List<ScheduleList> validSchedules) { int currentClass = Int32.Parse(rlist[rindex]); foreach (ClassSection cs in classList[currentClass].Sections) { if (tsl.DoesClassConflict(cs).Count == 0) { tsl.classes.Add(cs); if (rlist.Length - 1 == rindex) { validSchedules.Add(CopyScheduleList(tsl)); } else { SomeScheduleWorks(tsl, rlist, rindex + 1, validSchedules); } tsl.classes.RemoveAt(tsl.classes.Count - 1); } } }
private bool ScheduleWorks(ScheduleList tsl, string[] rlist, int rindex) { int currentClass = Int32.Parse(rlist[rindex]); foreach (ClassSection cs in classList[currentClass].Sections) { if (tsl.DoesClassConflict(cs).Count == 0) { tsl.classes.Add(cs); if (rlist.Length - 1 == rindex) { return true; } else { if (ScheduleWorks(tsl, rlist, rindex + 1)) { return true; } else { tsl.classes.RemoveAt(tsl.classes.Count - 1); } } } } return false; }
private string PrintDayScheduleToString(DayOfWeek sdow, ScheduleList tsl) { SortedDictionary<TimeFrame, ClassSection> cslist = new SortedDictionary<TimeFrame, ClassSection>(); StringBuilder sb = new StringBuilder(); sb.AppendLine("----" + Enum.GetName(typeof(DayOfWeek), sdow) + "----"); foreach (ClassSection csl in tsl.classes) { foreach (TimeFrame tf in csl.Times) { if (tf.StartTime.Day == sdow) { cslist.Add(tf, csl); //Console.WriteLine(string.Format("{0}:{1} - {2}:{3} {4}", tf.StartTime.Hour.ToString(), tf.StartTime.Minute.ToString() //, tf.EndTime.Hour.ToString(), tf.EndTime.Minute.ToString(), csl.parentClass.Title)); } } } foreach (TimeFrame tf in cslist.Keys) { sb.AppendLine(string.Format("{0}:{1} {5} - {2}:{3} {6} {4}", formatHour(tf.StartTime.Hour), tf.StartTime.Minute.ToString("00") , formatHour(tf.EndTime.Hour), tf.EndTime.Minute.ToString("00"), cslist[tf].parentClass.Title, AMPM(tf.StartTime.Hour), AMPM(tf.EndTime.Hour))); } return sb.ToString(); }
private List<ScheduleList> GetAllSchedulesEx(string[] rlist, int maxError) { ScheduleList tsl = new ScheduleList(); List<ScheduleList> validSchedules = new List<ScheduleList>(); SomeScheduleKindOfWorks(tsl, rlist, 0, validSchedules, 0, maxError); DeDupeList(validSchedules); return validSchedules; }
private List<ScheduleList> GetAllSchedules(string[] rlist) { ScheduleList tsl = new ScheduleList(); List<ScheduleList> validSchedules = new List<ScheduleList>(); SomeScheduleWorks(tsl, rlist, 0, validSchedules); return validSchedules; }
private ScheduleList CopyScheduleList(ScheduleList sl) { ScheduleList nsl = new ScheduleList(); foreach (ClassSection cs in sl.classes) { nsl.classes.Add(cs); } return nsl; }
public void ViewScheduleOptions() { bool c = true; int ind = 0; while (c) { ConsoleKeyInfo k = Console.ReadKey(true); if (k.Key == ConsoleKey.LeftArrow) { if (ind == 0) { ind = scheduleOptions.Count - 1; } else { ind--; } } else if (k.Key == ConsoleKey.RightArrow) { if (ind == scheduleOptions.Count - 1) { ind = 0; } else { ind++; } } else if (k.Key == ConsoleKey.Q) { c = true; break; } else if (k.Key == ConsoleKey.S) { sl = scheduleOptions[ind]; Console.WriteLine("Schedule selected"); c = false; break; } Console.Clear(); Console.WriteLine("Now Viewing Schedule " + ind.ToString()); SexyViewSchedule(scheduleOptions[ind]); Console.WriteLine(); Console.WriteLine("Press Q to quit or S to use this schedule"); } }
public void SmartScheduleClasses() { Console.WriteLine("Enter class numbers seperated by a comma"); string classR = Console.ReadLine(); string[] classReq = classR.Split(','); ScheduleList tsl = new ScheduleList(); if (ScheduleWorks(tsl, classReq, 0)) { sl.classes.AddRange(tsl.classes); Console.WriteLine("scheduleing sucessfull"); } else { Console.WriteLine("Unable to schedule classes"); } }
public void SexyViewSchedule(ScheduleList tsl) { PrintDaySchedule(DayOfWeek.Monday, tsl); PrintDaySchedule(DayOfWeek.Tuesday, tsl); PrintDaySchedule(DayOfWeek.Wednesday, tsl); PrintDaySchedule(DayOfWeek.Thursday, tsl); PrintDaySchedule(DayOfWeek.Friday, tsl); PrintDaySchedule(DayOfWeek.Saturday, tsl); PrintDaySchedule(DayOfWeek.Sunday, tsl); }
public string SexyScheduleToString(ScheduleList tsl) { StringBuilder sb = new StringBuilder(); sb.AppendLine(PrintDayScheduleToString(DayOfWeek.Monday, tsl)); sb.AppendLine(PrintDayScheduleToString(DayOfWeek.Tuesday, tsl)); sb.AppendLine(PrintDayScheduleToString(DayOfWeek.Wednesday, tsl)); sb.AppendLine(PrintDayScheduleToString(DayOfWeek.Thursday, tsl)); sb.AppendLine(PrintDayScheduleToString(DayOfWeek.Friday, tsl)); sb.AppendLine(PrintDayScheduleToString(DayOfWeek.Saturday, tsl)); sb.AppendLine(PrintDayScheduleToString(DayOfWeek.Sunday, tsl)); return sb.ToString(); }
private List<ScheduleList> GetAllSchedules(string[] rlist, Dictionary<int, string> restrictions) { ScheduleList tsl = new ScheduleList(); List<ScheduleList> validSchedules = new List<ScheduleList>(); SomeScheduleWorks(tsl, rlist, 0, validSchedules, restrictions); return validSchedules; }