Пример #1
0
 @Override
 public int compare(ClassStudent o1, ClassStudent o2) {
   if (o1.getCgpa() == o2.getCgpa()) {
     if (o1.getFname() == o2.getFname()) {
       return o2.getId() - o1.getId();
     } else return o1.getFname().compareTo(o2.getFname());
   }
   return Double.compare(o2.getCgpa(), o1.getCgpa());
 }
Пример #2
0
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int testCases = Integer.parseInt(in.nextLine());

    List<ClassStudent> studentList = new ArrayList<ClassStudent>();
    ListChecker check = new ListChecker();
    while (testCases > 0) {
      int id = in.nextInt();
      String fname = in.next();
      double cgpa = in.nextDouble();

      ClassStudent st = new ClassStudent(id, fname, cgpa);
      studentList.add(st);

      testCases--;
    }
    Collections.sort(studentList, check.desc);

    for (ClassStudent st : studentList) {
      System.out.println(st.getFname());
    }
  }