I am using my main method from class Test and am trying to call a function in an object, Course. This is the code from my main method:
if (decideStatus > .75) {
status = Classification.GRAD;
gradCount++;
if (gpa > 3.2) {
Student newStudent = new Student(sID, status, gpa);
**addStudentToRoster(newStudent);**
} else {
gradRejectCount++;
}
I am trying to use the addStudentToRoster function to add newStudent to the private variable
public class Course {
private int number = 0;
private String title = "";
private int capacity = 0;
//won't compile with float type for cutoff
private float cutoff = 0;
private ArrayList<Student> roster = new ArrayList<>();
private ArrayList<Student> waitlist = new ArrayList<>();
public Course(int number, String name, int maxSize, float cutoff) {
//set value of private fields
this.number = number;
this.title = name;
this.capacity = maxSize;
this.cutoff = cutoff;
}
public void addStudentToRoster(Student student) {
roster.add(student);
}
The addStudentToRoster(newStudent) line has an error stating that that method is undefined for that class. Does anyone know how I would fix this?