Iz E-študij, proste zakladnice študentskega znanja
public class Student extends Oseba{
private String fakulteta;
private short letoVpisa;
private String vrsta;
private boolean jeRedni;
private byte[][] izpiti;
public Student(String i, String p, Datum d, char s,
String E, String f, short l, String v,
boolean j, byte[][] iz){
super(i,p,d,s,E);
fakulteta=f;
letoVpisa=l;
vrsta=v;
jeRedni=j;
izpiti=iz;
}
public String toString(){
//Janez Novak, rojen(a), 1.4.1984, moski, 0104984500344 -/*iz Student*/FRI,
//2004, prvi vpis, redni, /*ocene*/{{7,7,6}{10,8,7,7}}
String s=super.toString()+"-"+fakulteta+", "+letoVpisa+
","+vrsta+","+(jeRedni?"redni":"izredni")+"{";
for(int i=0; i<izpiti.length; i++){
s=s+"{";
for(int j=0; j<izpiti[i].length; j++)
s=s+izpiti[i][j]+" ";
s=s+"}";
}
s=s+"}";
return s;
}
public boolean manjsi(Element b, byte smer, byte atr){
Student s=(Student) b;
boolean odg;
switch(atr){
case 1:
case 2:
case 3:
case 4:
case 5: odg=super.manjsi(b,smer,atr);
break;
case 6: odg=smer*fakulteta.compareTo(s.fakulteta)<0;
break;
case 7: odg=smer*letoVpisa<s.letoVpisa*smer;
break;
case 8: odg=smer*vrsta.compareTo(s.vrsta)<0;
break;
case 9: odg=smer*(jeRedni?1:0)<(s.jeRedni?1:0)*smer;
break;
case 10:
case 11:
case 12:
case 13:
case 14: odg=smer*vrednost(izpiti,atr)<vrednost(s.izpiti,atr)*smer;
break;
default: odg=false;
}
return odg;
}
public static double vrednost(byte[][]izp, byte atr){
int st=0, vsota=0;
byte min=11, max=0;
for(int i=0; i<izp.length; i++)
for(int j=0; j<izp[i].length; j++){
st++;
vsota+=izp[i][j];
if(min>izp[i][j])
min=izp[i][j];
if(max<izp[i][j])
max=izp[i][j];
}
double povp=((double)vsota)/st;
switch(atr){
case 10: return st;
case 11: return vsota;
case 12: return max;
case 13: return min;
case 14: return povp;
default: return 0;
}
}
public void izpisiTabelo(Element[] tb, byte atr){
Student[] ts=(Student[]) tb;
if(atr<6)
super.izpisiTabelo(tb,atr);
else{
for(int i=0; i<ts.length; i++)
switch(atr){
case 6: System.out.print(ts[i].fakulteta+" ");
break;
case 7: System.out.print(ts[i].letoVpisa+" ");
break;
case 8: System.out.print(ts[i].vrsta+" ");
break;
case 9: System.out.print(ts[i].jeRedni?"redni":"izredni"+" ");
break;
case 10:
case 11:
case 12:
case 13:
case 14:System.out.print(vrednost(ts[i].izpiti,atr)+" ");
break;
default:
}
System.out.println();
}
}
}