Implemented all methods marked with WIP
This commit is contained in:
@@ -15,30 +15,10 @@ import static org.lumijiez.enums.StudyField.DEFAULT_UNASSIGNED;
|
||||
public class StudentManager implements Serializable {
|
||||
private final List<Student> students = new ArrayList<>();
|
||||
|
||||
public void addStudent(FullStudentData data, Supervisor sv) {
|
||||
Faculty faculty;
|
||||
Group group;
|
||||
|
||||
if (Objects.isNull(sv.getFm().getFaculty(data.faculty()))) {
|
||||
Faculty newFaculty = new Faculty(data.faculty(), DEFAULT_UNASSIGNED.getAbbreviation(), DEFAULT_UNASSIGNED);
|
||||
sv.getFm().addFaculty(newFaculty);
|
||||
faculty = newFaculty;
|
||||
} else {
|
||||
faculty = sv.getFm().getFaculty(data.faculty());
|
||||
}
|
||||
|
||||
if (Objects.isNull(sv.getFm().getGm().getGroup(data.group()))) {
|
||||
Group newGroup = new Group("Unassigned");
|
||||
sv.getFm().getGm().addGroup(newGroup);
|
||||
group = newGroup;
|
||||
} else {
|
||||
group = sv.getFm().getGm().getGroup(data.group());
|
||||
}
|
||||
|
||||
Student newStudent = new Student(data.name(), data.surname(), group, faculty);
|
||||
students.add(newStudent);
|
||||
public void addStudent(Student student) {
|
||||
student.getGroup().addStudent(student);
|
||||
students.add(student);
|
||||
}
|
||||
|
||||
public List<Student> getStudents() {
|
||||
return students;
|
||||
}
|
||||
@@ -50,13 +30,8 @@ public class StudentManager implements Serializable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void deleteStudent(FullStudentData data) {
|
||||
students.removeIf(student ->
|
||||
student.getName().equals(data.name()) &&
|
||||
student.getSurname().equals(data.surname()) &&
|
||||
student.getGroup().getName().equals(data.group()) &&
|
||||
student.getFaculty().getName().equals(data.faculty())
|
||||
);
|
||||
public void deleteStudent(Student student) {
|
||||
students.remove(student);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import org.lumijiez.util.FullStudentData;
|
||||
import org.lumijiez.base.Student;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Supervisor implements Serializable {
|
||||
private final FacultyManager fm;
|
||||
@@ -15,6 +17,51 @@ public class Supervisor implements Serializable {
|
||||
this.fm = new FacultyManager();
|
||||
}
|
||||
|
||||
public void addFaculty(Faculty faculty) {
|
||||
getFm().addFaculty(faculty);
|
||||
}
|
||||
|
||||
public void deleteFaculty(Faculty faculty) {
|
||||
fm.deleteFaculty(faculty);
|
||||
for (Group gr : faculty.getGroups()) {
|
||||
getFm().getGm().deleteGroup(gr);
|
||||
for (Student st : gr.getStudents()) {
|
||||
getFm().getGm().getSm().deleteStudent(st);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void editGroup(Group group, String name, Faculty faculty) {
|
||||
group.setName(name);
|
||||
Faculty oldFac = group.getFaculty();
|
||||
group.setFaculty(faculty);
|
||||
faculty.addGroup(group);
|
||||
oldFac.getGroups().remove(group);
|
||||
}
|
||||
public void deleteGroup(Group group) {
|
||||
getFm().getGm().deleteGroup(group);
|
||||
for (Student st : group.getStudents()) {
|
||||
getFm().getGm().getSm().deleteStudent(st);
|
||||
}
|
||||
}
|
||||
|
||||
public void addStudent(String name, String surname, Group group, Faculty faculty, Date birth, Date enrol) {
|
||||
Student newStudent = new Student(name, surname, group, faculty, birth, enrol);
|
||||
getFm().getGm().getSm().addStudent(newStudent);
|
||||
group.addStudent(newStudent);
|
||||
}
|
||||
|
||||
public void addGroup(Group group, Faculty faculty) {
|
||||
group.setFaculty(faculty);
|
||||
faculty.addGroup(group);
|
||||
getFm().getGm().addGroup(group);
|
||||
}
|
||||
|
||||
public void deleteStudent(Student st) {
|
||||
st.getGroup().deleteStudent(st);
|
||||
getFm().getGm().getSm().deleteStudent(st);
|
||||
}
|
||||
|
||||
public String getStudentsText() {
|
||||
StringBuilder info = new StringBuilder();
|
||||
for (Student st : fm.getGm().getSm().getStudents()) {
|
||||
|
||||
Reference in New Issue
Block a user