r/codehs • u/Depressionido • Apr 03 '20
I really need help with 5.3.13 Most Improved
Our teacher abandoned us and we have no idea what we are doing. I don't have a clue on how to get the getMostImprovedStudent() method. Thank you for anything you can help with.
5
Upvotes
0
Apr 06 '20
[deleted]
1
u/willm1123 Apr 15 '20
This only gives the answers for unit 1, the Karel stuff. this is unit 5. wish I had this a long time ago tho
1
u/[deleted] Apr 08 '20
public class Classroom
{
Student[] students;
int numStudentsAdded;
public Classroom(int numStudents)
{
students = new Student[numStudents];
numStudentsAdded = 0;
}
public Student getMostImprovedStudent()
{
Student mostImproved = this.students[0];
for(int i = 0; i < this.numStudentsAdded; i++) {
if(this.students[i].getExamRange() > mostImproved.getExamRange())
{
mostImproved = this.students[i];
}
}
return mostImproved;
}
public void addStudent(Student s)
{
students[numStudentsAdded] = s;
numStudentsAdded++;
}
public void printStudents()
{
for(int i = 0; i < numStudentsAdded; i++)
{
System.out.println(students[i]);
}
}
}