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