Пример #1
0
 public static void FilterAndTake(Dictionary <string, List <int> > wantedData, string wantedFilter, int studentsToTake)
 {
     if (wantedFilter == "excellent")
     {
         FilterAndTake(wantedData, x => x >= 5, studentsToTake);
     }
     else if (wantedFilter == "average")
     {
         FilterAndTake(wantedData, x => x >= 3.5 && x < 5, studentsToTake);
     }
     else if (wantedFilter == "poor")
     {
         FilterAndTake(wantedData, x => x < 3.5, studentsToTake);
     }
     else
     {
         OutputWriter.DisplayExeptions(ExceptionMessages.InvalidStudentFilter);
     }
 }
Пример #2
0
 public static void OrderAndTake(Dictionary <string, List <int> > wantedData, string comparision, int studentsToTake)
 {
     comparision = comparision.ToLower();
     if (comparision == "ascending")
     {
         PrintStudents(wantedData.OrderBy(x => x.Value.Sum())
                       .Take(studentsToTake)
                       .ToDictionary(pair => pair.Key, pair => pair.Value));
     }
     else if (comparision == "descending")
     {
         PrintStudents(wantedData.OrderByDescending(x => x.Value.Sum())
                       .Take(studentsToTake)
                       .ToDictionary(pair => pair.Key, pair => pair.Value));
     }
     else
     {
         OutputWriter.DisplayExeptions(ExceptionMessages.InvalidComparisonQuery);
     }
 }