53 lines
895 B
Java
53 lines
895 B
Java
package dev.service;
|
|
|
|
import dev.model.Student;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
public class StudentManager {
|
|
|
|
private final ArrayList<Student> students = new ArrayList<>();
|
|
|
|
public void addStudents(ArrayList<Student> newStudents) {
|
|
|
|
students.addAll(newStudents);
|
|
}
|
|
|
|
public Student searchStudent(int id) {
|
|
|
|
for (Student s : students)
|
|
{
|
|
if (id == s.getId())
|
|
{
|
|
return s;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public boolean removeStudent(int id) {
|
|
|
|
for (Student s : students)
|
|
{
|
|
if (id == s.getId())
|
|
{
|
|
students.remove(s);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public void printStudents() {
|
|
|
|
for (Student student : students) {
|
|
|
|
System.out.println(student);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |