implement StudentManager.java
This commit is contained in:
@@ -11,35 +11,24 @@ public class StudentManager {
|
||||
|
||||
public void addStudents(ArrayList<Student> newStudents) {
|
||||
|
||||
// TODO:
|
||||
|
||||
// Merge students
|
||||
|
||||
// Hint:
|
||||
// addAll()
|
||||
if(newStudents != null){
|
||||
this.students.addAll(newStudents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Student searchStudent(int id) {
|
||||
|
||||
// TODO:
|
||||
|
||||
// Loop through students
|
||||
|
||||
// Compare IDs
|
||||
for(Student s : students) {
|
||||
if(s.getId() == id ) return s;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean removeStudent(int id) {
|
||||
|
||||
// TODO:
|
||||
|
||||
// Find student
|
||||
|
||||
// Remove student
|
||||
|
||||
return false;
|
||||
return students.removeIf(s -> s.getId() == id);
|
||||
}
|
||||
|
||||
public void printStudents() {
|
||||
|
||||
Reference in New Issue
Block a user