Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
1
Indexable
Never
public static void RangLista(Ispitni_Rok isprok){
    ArrayList<Student> studenti = new ArrayList<>();
    for(Ispit i: isprok.lista_ispita){
        if(!studenti.contains(i.student))
            studenti.add(i.student);
    }

    ArrayList<Integer> bodovi = new ArrayList<>();
    for(Student s: studenti){
        int sumaBodova = 0;
        for(Ispit i: isprok.lista_ispita){
            if(s == i.student && i.ocena > 5){
                sumaBodova = sumaBodova + i.espb;
            }
        }
        bodovi.add(sumaBodova);
    }

    for (int i = 0; i < bodovi.size(); i++) {
        for (int j = bodovi.size() - 1; j > i; j--) {
            if (bodovi.get(i) > bodovi.get(j)) {
                int tmp = bodovi.get(i);
                Student stu = studenti.get(i);
                bodovi.set(i,bodovi.get(j));
                bodovi.set(j,tmp);
                studenti.set(i, studenti.get(i));
                studenti.set(j,stu);
            }
        }
    }

    for(int i = 0; i < studenti.size(); i++){
        System.out.println(studenti.get(i).ime + ": " + bodovi.get(i));
    }
    
}