package VorlesungsFolien.SortierenmitComparatoren_Comparable;

import java.util.*;

public class Student {
    private int matrikelNummer;
    private String name;

    // Konstruktor
    public Student(int matrikelNummer, String name) {
        this.matrikelNummer = matrikelNummer;
        this.name = name;
    }

    // toString-Methode
    public String toString() {
        return matrikelNummer + " - " + name;
    }

  
    
    
    public static void main(String[] args) {
    	Comparator<Student> com = new Comparator<>() {

			@Override
			public int compare(Student o1, Student o2) {
				if (o1.matrikelNummer%10 > o2.matrikelNummer%10)
					return 1;
				else
					return -1;
			}
    		
    	};
    	
    	Comparator<Student> name = new Comparator<>() {

			@Override
			public int compare(Student o1, Student o2) {
				if (o1.name.charAt(1) > o2.name.charAt(1))
					return 1;
				else
					return -1;
			}
    		
    	};
    	
    	List<Student> studenten = new ArrayList<>();
    	studenten.add(new Student(4411,"AH"));
    	studenten.add(new Student(5714,"AA"));
    	studenten.add(new Student(4713,"AC"));
    	
    	Collections.sort(studenten,name);
    	for (Student s : studenten)
    		System.out.println(s);
    	
    
    }
}

