Commit b11720b9 authored by MostafaRahmati's avatar MostafaRahmati

last question is not solved yet

parent 4aaca3fb
...@@ -29,6 +29,7 @@ public class College { ...@@ -29,6 +29,7 @@ public class College {
facultyLabs=new Lab[labCount]; facultyLabs=new Lab[labCount];
Student sampleStudent = new Student("Foo", "Bar", "99xxxxxx"); Student sampleStudent = new Student("Foo", "Bar", "99xxxxxx");
for (int i = 0; i < facultyLabs.length; i++) { for (int i = 0; i < facultyLabs.length; i++) {
facultyLabs[i] = new Lab(5, "dAy oF cLaSs");
facultyLabs[i].enrollStudent(sampleStudent); facultyLabs[i].enrollStudent(sampleStudent);
} }
} }
...@@ -39,8 +40,15 @@ public class College { ...@@ -39,8 +40,15 @@ public class College {
*/ */
public void print(int i){ public void print(int i){
if(i>facultyLabs.length) if(i>facultyLabs.length)
System.out.println("Faculty Has Not That Lab Class"); System.out.println("Faculty Has Not Lab Class No."+i);
else else{
facultyLabs[i-1].print(); try {
facultyLabs[i-1].print();
}
catch (Exception e){
System.out.println("");
}
}
} }
} }
...@@ -54,8 +54,10 @@ public class Lab { ...@@ -54,8 +54,10 @@ public class Lab {
*/ */
public void print() { public void print() {
for (int i = 0; i < students.length; i++) { for (int i = 0; i < students.length; i++) {
System.out.println("FirstName: " + students[i].getFirstName() + "\tLastName: " + students[i].getLastName() + if (students[i]!=null){
"\t\tID:" + students[i].getId() + "\t\tGrade:" + students[i].getGrade()); System.out.println("FirstName: " + students[i].getFirstName() + "\tLastName: " + students[i].getLastName() +
"\t\tID:" + students[i].getId() + "\t\tGrade:" + students[i].getGrade());
}
} }
calculateAvg(); calculateAvg();
System.out.println("AVERAGE GRADE: " + getAvg()); System.out.println("AVERAGE GRADE: " + getAvg());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment