so when i try to run my Group class, it tells me that the content of the student array is null and i cant find where specifically (been spending the last 4 hours trying to figured it out).if you have any questions regarding of classes, dont hesitate to ask.
thanks in advance for all of your answers.
Group class
public class Group {
private Student studentArray[];
private int nbOfStudent;
public Group() {
studentArray[]= new Student[24];
}
public void add( Student stud){
studentArray[nbOfStudent]=stud;
nbOfStudent++;
}
public String toString(){
String msg="";
for(int i=0;i<studentArray.length;i++){
msg+=tabStudent[i]+" ";
}
return msg;
}
public Student getStudentArray(int i) {
return studentArray[i];
}
public Student[] getstudentArray(){
return studentArray;
}
public void setStudentArray[](Student[] studentArray) {
this.studentArray= studentArray;
}
public int getNbOfStudent() {
return nbOfStudent;
}
public void setNbOfStudent(int student) {
this.nbOfStudent = student;
}
public int search(String code){
return UtilsTabs.search(studentArray, code,this.nbOfStudent);
}
public void sort(){
UtilsTabs.sort(studentArray, nbOfStudent);
}
}
UtilsTabs class
public static void sort(Student[] array, int nbOfStud){
Student temp=null;
int minIndex=0;
for(int i=0;i<array.length-1;i++){
minIndex=i;
for(int j=i+1;j<nbOfStud;j++){
int comparedValue = tab[j].compareTo(tab[minIndex]);
if( comparedValue< 0){
minIndex=j;
}
}
temp=tab[i];
array[i]=array[minIndex];
array[minIndex]=temp;
}
}
public static int search(Student array[],String code,int nbofStud){
int pos=-1;
for(int i=0;i<tarray.length;i++){
if(tab[i].getCode().equalsIgnoreCase(code));
pos=i;
}
return pos;
}
Student class
public class Student {
private String code;
private String name;
private Grades evaluation;
public Student(String code, String name, String eval) {
this.code = code;
this.nom = nom;
this.evaluation=new Grades(eval);
}
public Message message(){
if(this.evaluation.gradeAverage()<60)
return Message.FAILED;
else
return Message.SUCCESS;
}
public boolean equals(Student other){
boolean res=this.code.equals(other.code);
return res;
}
public int compareTo(Student other){
int res= this.code.compareTo(other.code);
return res;
}
}
test of class group
Group gr = new Group();
Student stud2 = new Student("26161234", "Marc", "65 81 58 100 79");
gr.add(stud2);
Student stud=new Student("24910003", "Pierre", "45 59 36 66");
gr.add(stud);
//show group of student
System.out.println("Group of students:\n" + gr.toString());
this is what the console shows me