Q: What (if any) argument gets passed in to studentList.addStudent()
?
A: That depends entirely on what parameters the addStudent()
method of “studentList’s` class takes.
In your case:
-
studentList
is aManager
(poor name for either variable or class, but..) -
Manager.addStudent()
takes an object of class typeStudent
. -
You need to have an object of type
Student
available when you calladdStudent
.
One of your challenges in your code is that you currently have no way of giving a “Student” a name or student ID. That’s a problem.
Two solutions:
a) Create “setter” methods for name etc.
… and/or …
b) Create a constructor that accepts name etc. as parameters.
solved What goes in to the parentheses of studentList.addStudent()? [closed]