stick the student objects in an Object[] o = new Object[10]
and when you get them out of the array cast them back as Student objects by doing (Student)o[i];
you cant use Arrays.sort because you have not implemented Comparable so it cannot do natural order sorting, which is why you have to write your own (which needs a swap method).
Also never access variables directly always make get and set methods
To sort by quizes (make a method which does this)
Code:
public int[] getQuizes() {
return q;
}
public String getName() {
return name;
}
public Student sortQuizes(Student a) {
int[] qTemp = a.getQuizes();
for(int i=qTemp.length-1; i >= 1; i--) {
for(int j = 1; j < i; j++) {
if ( qTemp[j-1] < qtemp[j] )
swap(a, j-1, j);
}
}
}
protected static void swap(int[] array, int i, int j) {
int temp;
temp = array[i];
array[i] = array[j];
array[j] = temp;;
}//end swap
this will sort the quizes
for names
Code:
public Student[] sortNames(Student[] sTemp) {
for(int i=sTemp.length-1; i >= 1; i--) {
for(int j = 1; j < i; j++) {
String n = sTemp[j-1].getName();
String n2 = sTemp[j].getName();
if ( n.compareTo(n2) > 0 )
swap(sTemp, j-1 , j);
}
}
}
gah something along these lines should work...