I've got two classes, LabClass
and Student
with students being enrolled in the class and given grades.
I've called Student
into LabClass
as an ArrayList using the following:
private List<Student> students;
Now, I want to be able to individually allocate grades to each student after they have been enrolled.
I've created a method in the Student
class to allocate grades and tried to call upon it in LabClass
, but it didn't work.
The code in Student
is as follows:
public void grade(int marks){
grades = marks;
}
And I tried to call it within LabClass
with the following code:
public void giveGrades(){
for(Student student : students){
student.grade(int marks);
}
}
But I get returned the error ".class expected". What's wrong with my code?
Should I be using the set
command of Arrays to change the element's value? If so, how should I write it such that it can take in external values from a parameter? Also, how do I specify which value of the element is being changed?