-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentManager
More file actions
73 lines (64 loc) · 1.8 KB
/
StudentManager
File metadata and controls
73 lines (64 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.util.ArrayList;
/**
* This class represents multiple students.
*/
public class StudentManager {
private ArrayList<Student> students;
/**
* This is the constructor for the StudentManager class.
*
* @param students The students to add to the database.
*/
public StudentManager() {
students = new ArrayList<Student>();
}
/**
* This method adds a student to the database.
*/
public void addStudent(Student student) {
students.add(student);
}
/**
* This method returns a student from the database.
*
* @param id The ID of the student to return.
* @return The student with the given ID.
*/
public Student getStudent(String id) {
for (Student student : students) {
if (student.getID().equals(id)) {
return student;
}
}
return null;
}
/**
* This method removes a student from the database.
*
* @param student The student to remove.
*/
public void removeStudent(Student student) {
students.remove(student);
}
/**
* This method modifies a student's information.
*
* @param student The student to modify.
* @param firstName The new first name of the student.
* @param lastName The new last name of the student.
* @param id The new ID of the student.
*/
public void modifyStudent(Student student, String firstName, String lastName, String id) {
student.setFirstName(firstName);
student.setLastName(lastName);
student.setID(id);
}
/**
* This method returns all students in the database.
*
* @return All students in the database.
*/
public ArrayList<Student> getStudents() {
return students;
}
}