Implemented UI, fixed serialization inconsistency
This commit is contained in:
@@ -9,6 +9,8 @@ public class Group implements Serializable {
|
|||||||
|
|
||||||
private Faculty faculty;
|
private Faculty faculty;
|
||||||
|
|
||||||
|
private List<Student> students = new ArrayList<>();
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
@@ -25,8 +27,6 @@ public class Group implements Serializable {
|
|||||||
this.students = students;
|
this.students = students;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Student> students = new ArrayList<>();
|
|
||||||
|
|
||||||
public Group(String name) {
|
public Group(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,53 @@
|
|||||||
package org.lumijiez.base;
|
package org.lumijiez.base;
|
||||||
|
|
||||||
|
import org.lumijiez.util.FullStudentData;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Student implements Serializable {
|
public class Student implements Serializable {
|
||||||
|
|
||||||
|
public Student(String name, String surname, Group group, Faculty faculty) {
|
||||||
|
this.name = name;
|
||||||
|
this.surname = surname;
|
||||||
|
this.fullname = name + " " + surname;
|
||||||
|
this.group = group;
|
||||||
|
this.FSD = new FullStudentData(name, surname, group.getName(), faculty.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
private String fullname;
|
private String fullname;
|
||||||
private String email;
|
private String email;
|
||||||
private Date enrollmentDate;
|
private Date enrollmentDate;
|
||||||
|
|
||||||
private Date dateOfBirth;
|
private Date dateOfBirth;
|
||||||
|
private Faculty faculty;
|
||||||
|
private Group group;
|
||||||
|
// This acts like an identification serial number for each student
|
||||||
|
private FullStudentData FSD;
|
||||||
|
private final List<Grade> grades = new ArrayList<>();
|
||||||
|
|
||||||
// Student stores a reference to its own Group and Faculty, bidirectional association
|
// Student stores a reference to its own Group and Faculty, bidirectional association
|
||||||
private Group group;
|
|
||||||
|
|
||||||
public Faculty getFaculty() {
|
public Faculty getFaculty() {
|
||||||
return faculty;
|
return faculty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FullStudentData getFSD() {
|
||||||
|
return FSD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFSD(FullStudentData FSD) {
|
||||||
|
this.FSD = FSD;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFaculty(Faculty faculty) {
|
public void setFaculty(Faculty faculty) {
|
||||||
this.faculty = faculty;
|
this.faculty = faculty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Faculty faculty;
|
|
||||||
|
|
||||||
private final List<Grade> grades = new ArrayList<>();
|
|
||||||
|
|
||||||
public Student(String name, String surname, Group group) {
|
|
||||||
this.name = name;
|
|
||||||
this.surname = surname;
|
|
||||||
this.fullname = name + " " + surname;
|
|
||||||
this.group = group;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGroup(Group gr) {
|
public void setGroup(Group gr) {
|
||||||
this.group.deleteStudent(this);
|
this.group.deleteStudent(this);
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package org.lumijiez.gui.forms;
|
package org.lumijiez.gui.forms;
|
||||||
|
|
||||||
import org.lumijiez.base.Grade;
|
import org.lumijiez.base.Grade;
|
||||||
import org.lumijiez.util.NameSurnameGroup;
|
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
import org.lumijiez.util.FullStudentData;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class AddGradeForm extends JFrame {
|
public class AddGradeForm extends JFrame {
|
||||||
public AddGradeForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
|
public AddGradeForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
|
||||||
this.setTitle("Add Grade");
|
this.setTitle("Add Grade");
|
||||||
this.setSize(400, 300);
|
this.setSize(400, 300);
|
||||||
this.setLocation(centerX, centerY);
|
this.setLocation(centerX, centerY);
|
||||||
@@ -21,6 +21,8 @@ public class AddGradeForm extends JFrame {
|
|||||||
JTextField surnameField = new JTextField();
|
JTextField surnameField = new JTextField();
|
||||||
JLabel groupLabel = new JLabel("Group:");
|
JLabel groupLabel = new JLabel("Group:");
|
||||||
JTextField groupField = new JTextField();
|
JTextField groupField = new JTextField();
|
||||||
|
JLabel facultyLabel = new JLabel("Faculty:");
|
||||||
|
JTextField facultyField = new JTextField();
|
||||||
JLabel subjectLabel = new JLabel("Subject:");
|
JLabel subjectLabel = new JLabel("Subject:");
|
||||||
JTextField subjectField = new JTextField();
|
JTextField subjectField = new JTextField();
|
||||||
JLabel gradeLabel = new JLabel("Grade:");
|
JLabel gradeLabel = new JLabel("Grade:");
|
||||||
@@ -28,12 +30,15 @@ public class AddGradeForm extends JFrame {
|
|||||||
|
|
||||||
JButton submitButton = new JButton("Submit");
|
JButton submitButton = new JButton("Submit");
|
||||||
|
|
||||||
|
|
||||||
formPanel.add(nameLabel);
|
formPanel.add(nameLabel);
|
||||||
formPanel.add(nameField);
|
formPanel.add(nameField);
|
||||||
formPanel.add(surnameLabel);
|
formPanel.add(surnameLabel);
|
||||||
formPanel.add(surnameField);
|
formPanel.add(surnameField);
|
||||||
formPanel.add(groupLabel);
|
formPanel.add(groupLabel);
|
||||||
formPanel.add(groupField);
|
formPanel.add(groupField);
|
||||||
|
formPanel.add(facultyLabel);
|
||||||
|
formPanel.add(facultyField);
|
||||||
formPanel.add(subjectLabel);
|
formPanel.add(subjectLabel);
|
||||||
formPanel.add(subjectField);
|
formPanel.add(subjectField);
|
||||||
formPanel.add(gradeLabel);
|
formPanel.add(gradeLabel);
|
||||||
@@ -48,10 +53,11 @@ public class AddGradeForm extends JFrame {
|
|||||||
String group = groupField.getText();
|
String group = groupField.getText();
|
||||||
String subject = subjectField.getText();
|
String subject = subjectField.getText();
|
||||||
String grade = gradeField.getText();
|
String grade = gradeField.getText();
|
||||||
|
String faculty = facultyField.getText();
|
||||||
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !subject.isEmpty() && !grade.isEmpty()) {
|
FullStudentData data = new FullStudentData(name, surname, group, faculty);
|
||||||
studentManager.addGrade(new NameSurnameGroup(name, surname, group), new Grade(subject, Integer.parseInt(grade)));
|
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !subject.isEmpty() && !grade.isEmpty() && !faculty.isEmpty()) {
|
||||||
outputTextArea.setText("===== Students =====\n" + studentManager.getStudentsText());
|
sv.getFm().getGm().getSm().getStudent(data).addGrade(new Grade(subject, Integer.parseInt(grade)));
|
||||||
|
outputTextArea.setText("===== Students =====\n" + sv.getStudentsText());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package org.lumijiez.gui.forms;
|
package org.lumijiez.gui.forms;
|
||||||
|
|
||||||
import org.lumijiez.util.NameSurnameGroup;
|
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
import org.lumijiez.util.FullStudentData;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class AddStudentForm extends JFrame {
|
public class AddStudentForm extends JFrame {
|
||||||
public AddStudentForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
|
public AddStudentForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
|
||||||
this.setTitle("Add Student");
|
this.setTitle("Add Student");
|
||||||
this.setSize(400, 300);
|
this.setSize(400, 300);
|
||||||
this.setLocation(centerX, centerY);
|
this.setLocation(centerX, centerY);
|
||||||
@@ -20,6 +20,8 @@ public class AddStudentForm extends JFrame {
|
|||||||
JTextField surnameField = new JTextField();
|
JTextField surnameField = new JTextField();
|
||||||
JLabel groupLabel = new JLabel("Group:");
|
JLabel groupLabel = new JLabel("Group:");
|
||||||
JTextField groupField = new JTextField();
|
JTextField groupField = new JTextField();
|
||||||
|
JLabel facultyLabel = new JLabel("Faculty:");
|
||||||
|
JTextField facultyField = new JTextField();
|
||||||
JButton submitButton = new JButton("Submit");
|
JButton submitButton = new JButton("Submit");
|
||||||
|
|
||||||
formPanel.add(nameLabel);
|
formPanel.add(nameLabel);
|
||||||
@@ -28,6 +30,8 @@ public class AddStudentForm extends JFrame {
|
|||||||
formPanel.add(surnameField);
|
formPanel.add(surnameField);
|
||||||
formPanel.add(groupLabel);
|
formPanel.add(groupLabel);
|
||||||
formPanel.add(groupField);
|
formPanel.add(groupField);
|
||||||
|
formPanel.add(facultyLabel);
|
||||||
|
formPanel.add(facultyField);
|
||||||
formPanel.add(submitButton);
|
formPanel.add(submitButton);
|
||||||
|
|
||||||
this.add(formPanel);
|
this.add(formPanel);
|
||||||
@@ -36,9 +40,11 @@ public class AddStudentForm extends JFrame {
|
|||||||
String name = nameField.getText();
|
String name = nameField.getText();
|
||||||
String surname = surnameField.getText();
|
String surname = surnameField.getText();
|
||||||
String group = groupField.getText();
|
String group = groupField.getText();
|
||||||
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty()) {
|
String faculty = facultyField.getText();
|
||||||
studentManager.addStudent(new NameSurnameGroup(name, surname, group));
|
FullStudentData data = new FullStudentData(name, surname, group, faculty);
|
||||||
outputTextArea.setText("===== Students =====\n" + studentManager.getStudentsText());
|
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !faculty.isEmpty()) {
|
||||||
|
sv.getFm().getGm().getSm().addStudent(data);
|
||||||
|
outputTextArea.setText("===== Students =====\n" + sv.getStudentsText());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package org.lumijiez.gui.forms;
|
package org.lumijiez.gui.forms;
|
||||||
|
|
||||||
import org.lumijiez.util.NameSurnameGroup;
|
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
import org.lumijiez.util.FullStudentData;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class ChangeGroupForm extends JFrame {
|
public class ChangeGroupForm extends JFrame {
|
||||||
public ChangeGroupForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
|
public ChangeGroupForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
|
||||||
this.setTitle("Change Group");
|
this.setTitle("Change Group");
|
||||||
this.setSize(400, 300);
|
this.setSize(400, 300);
|
||||||
this.setLocation(centerX, centerY);
|
this.setLocation(centerX, centerY);
|
||||||
@@ -20,6 +20,8 @@ public class ChangeGroupForm extends JFrame {
|
|||||||
JTextField surnameField = new JTextField();
|
JTextField surnameField = new JTextField();
|
||||||
JLabel groupLabel = new JLabel("Group:");
|
JLabel groupLabel = new JLabel("Group:");
|
||||||
JTextField groupField = new JTextField();
|
JTextField groupField = new JTextField();
|
||||||
|
JLabel facultyLabel = new JLabel("Faculty:");
|
||||||
|
JTextField facultyField = new JTextField();
|
||||||
JLabel newgroupLabel = new JLabel("New Group:");
|
JLabel newgroupLabel = new JLabel("New Group:");
|
||||||
JTextField newgroupField = new JTextField();
|
JTextField newgroupField = new JTextField();
|
||||||
JButton submitButton = new JButton("Submit");
|
JButton submitButton = new JButton("Submit");
|
||||||
@@ -30,6 +32,8 @@ public class ChangeGroupForm extends JFrame {
|
|||||||
formPanel.add(surnameField);
|
formPanel.add(surnameField);
|
||||||
formPanel.add(groupLabel);
|
formPanel.add(groupLabel);
|
||||||
formPanel.add(groupField);
|
formPanel.add(groupField);
|
||||||
|
formPanel.add(facultyLabel);
|
||||||
|
formPanel.add(facultyField);
|
||||||
formPanel.add(newgroupLabel);
|
formPanel.add(newgroupLabel);
|
||||||
formPanel.add(newgroupField);
|
formPanel.add(newgroupField);
|
||||||
formPanel.add(submitButton);
|
formPanel.add(submitButton);
|
||||||
@@ -41,9 +45,11 @@ public class ChangeGroupForm extends JFrame {
|
|||||||
String surname = surnameField.getText();
|
String surname = surnameField.getText();
|
||||||
String group = groupField.getText();
|
String group = groupField.getText();
|
||||||
String newgroup = newgroupField.getText();
|
String newgroup = newgroupField.getText();
|
||||||
|
String faculty = facultyField.getText();
|
||||||
|
FullStudentData data = new FullStudentData(name, surname, group, faculty);
|
||||||
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !newgroup.isEmpty()) {
|
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !newgroup.isEmpty()) {
|
||||||
studentManager.changeGroup(new NameSurnameGroup(name, surname, group), newgroup);
|
//studentManager.changeGroup(new NameSurnameGroup(name, surname, group), newgroup);
|
||||||
outputTextArea.setText("===== Groups =====\n" + studentManager.getGroupsText());
|
outputTextArea.setText("===== Groups =====\n" + sv.getGroupsText());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package org.lumijiez.gui.forms;
|
package org.lumijiez.gui.forms;
|
||||||
|
|
||||||
import org.lumijiez.util.NameSurnameGroup;
|
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
import org.lumijiez.util.FullStudentData;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class DeleteStudentForm extends JFrame {
|
public class DeleteStudentForm extends JFrame {
|
||||||
public DeleteStudentForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
|
public DeleteStudentForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
|
||||||
this.setTitle("Delete Student");
|
this.setTitle("Delete Student");
|
||||||
this.setSize(400, 300);
|
this.setSize(400, 300);
|
||||||
this.setLocation(centerX, centerY);
|
this.setLocation(centerX, centerY);
|
||||||
@@ -20,6 +20,8 @@ public class DeleteStudentForm extends JFrame {
|
|||||||
JTextField surnameField = new JTextField();
|
JTextField surnameField = new JTextField();
|
||||||
JLabel groupLabel = new JLabel("Group:");
|
JLabel groupLabel = new JLabel("Group:");
|
||||||
JTextField groupField = new JTextField();
|
JTextField groupField = new JTextField();
|
||||||
|
JLabel facultyLabel = new JLabel("Faculty:");
|
||||||
|
JTextField facultyField = new JTextField();
|
||||||
JButton submitButton = new JButton("Submit");
|
JButton submitButton = new JButton("Submit");
|
||||||
|
|
||||||
formPanel.add(nameLabel);
|
formPanel.add(nameLabel);
|
||||||
@@ -28,6 +30,8 @@ public class DeleteStudentForm extends JFrame {
|
|||||||
formPanel.add(surnameField);
|
formPanel.add(surnameField);
|
||||||
formPanel.add(groupLabel);
|
formPanel.add(groupLabel);
|
||||||
formPanel.add(groupField);
|
formPanel.add(groupField);
|
||||||
|
formPanel.add(facultyLabel);
|
||||||
|
formPanel.add(facultyField);
|
||||||
formPanel.add(submitButton);
|
formPanel.add(submitButton);
|
||||||
|
|
||||||
this.add(formPanel);
|
this.add(formPanel);
|
||||||
@@ -36,9 +40,11 @@ public class DeleteStudentForm extends JFrame {
|
|||||||
String name = nameField.getText();
|
String name = nameField.getText();
|
||||||
String surname = surnameField.getText();
|
String surname = surnameField.getText();
|
||||||
String group = groupField.getText();
|
String group = groupField.getText();
|
||||||
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty()) {
|
String faculty = facultyField.getText();
|
||||||
studentManager.removeStudent(new NameSurnameGroup(name, surname, group));
|
FullStudentData data = new FullStudentData(name, surname, group, faculty);
|
||||||
outputTextArea.setText("===== Students =====\n" + studentManager.getStudentsText());
|
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !faculty.isEmpty()) {
|
||||||
|
sv.getFm().getGm().getSm().deleteStudent(data);
|
||||||
|
outputTextArea.setText("===== Students =====\n" + sv.getStudentsText());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package org.lumijiez.gui.forms;
|
package org.lumijiez.gui.forms;
|
||||||
|
|
||||||
import org.lumijiez.util.NameSurnameGroup;
|
import org.lumijiez.util.FullStudentData;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class ShowGradesForm extends JFrame {
|
public class ShowGradesForm extends JFrame {
|
||||||
public ShowGradesForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
|
public ShowGradesForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
|
||||||
this.setTitle("Show Grades Student");
|
this.setTitle("Show Grades Student");
|
||||||
this.setSize(400, 300);
|
this.setSize(400, 300);
|
||||||
this.setLocation(centerX, centerY);
|
this.setLocation(centerX, centerY);
|
||||||
@@ -20,6 +20,8 @@ public class ShowGradesForm extends JFrame {
|
|||||||
JTextField surnameField = new JTextField();
|
JTextField surnameField = new JTextField();
|
||||||
JLabel groupLabel = new JLabel("Group:");
|
JLabel groupLabel = new JLabel("Group:");
|
||||||
JTextField groupField = new JTextField();
|
JTextField groupField = new JTextField();
|
||||||
|
JLabel facultyLabel = new JLabel("Faculty:");
|
||||||
|
JTextField facultyField = new JTextField();
|
||||||
JButton submitButton = new JButton("Submit");
|
JButton submitButton = new JButton("Submit");
|
||||||
|
|
||||||
formPanel.add(nameLabel);
|
formPanel.add(nameLabel);
|
||||||
@@ -28,6 +30,8 @@ public class ShowGradesForm extends JFrame {
|
|||||||
formPanel.add(surnameField);
|
formPanel.add(surnameField);
|
||||||
formPanel.add(groupLabel);
|
formPanel.add(groupLabel);
|
||||||
formPanel.add(groupField);
|
formPanel.add(groupField);
|
||||||
|
formPanel.add(facultyLabel);
|
||||||
|
formPanel.add(facultyField);
|
||||||
formPanel.add(submitButton);
|
formPanel.add(submitButton);
|
||||||
|
|
||||||
this.add(formPanel);
|
this.add(formPanel);
|
||||||
@@ -36,9 +40,10 @@ public class ShowGradesForm extends JFrame {
|
|||||||
String name = nameField.getText();
|
String name = nameField.getText();
|
||||||
String surname = surnameField.getText();
|
String surname = surnameField.getText();
|
||||||
String group = groupField.getText();
|
String group = groupField.getText();
|
||||||
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty()) {
|
String faculty = facultyField.getText();
|
||||||
NameSurnameGroup nsg = new NameSurnameGroup(name, surname, group);
|
FullStudentData data = new FullStudentData(name, surname, group, faculty);
|
||||||
outputTextArea.setText("===== Grades =====\n" + name + " " + surname + "\n" + studentManager.getGradesText(nsg));
|
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !faculty.isEmpty()) {
|
||||||
|
outputTextArea.setText("===== Grades =====\n" + name + " " + surname + "\n" + sv.getGradesText(data));
|
||||||
this.dispose();
|
this.dispose();
|
||||||
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,20 +8,21 @@ import java.util.List;
|
|||||||
|
|
||||||
public class FacultyManager implements Serializable {
|
public class FacultyManager implements Serializable {
|
||||||
|
|
||||||
public FacultyManager(GroupManager gm, StudentManager sm) {
|
private final StudentManager sm = new StudentManager();
|
||||||
this.gm = new GroupManager(sm);
|
private final GroupManager gm = new GroupManager(sm);
|
||||||
this.sm = sm;
|
|
||||||
}
|
|
||||||
private final GroupManager gm;
|
|
||||||
private final StudentManager sm;
|
|
||||||
private final List<Faculty> faculties = new ArrayList<>();
|
private final List<Faculty> faculties = new ArrayList<>();
|
||||||
|
|
||||||
public Faculty getFaculty(String facultyName, GroupManager gm) {
|
public Faculty getFaculty(String facultyName) {
|
||||||
for (Faculty fc : faculties)
|
for (Faculty fc : faculties)
|
||||||
if (fc.getName().equals(facultyName)) return fc;
|
if (fc.getName().equals(facultyName)) return fc;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GroupManager getGm() {
|
||||||
|
return gm;
|
||||||
|
}
|
||||||
|
|
||||||
public void addFaculty(Faculty faculty) {
|
public void addFaculty(Faculty faculty) {
|
||||||
faculties.add(faculty);
|
faculties.add(faculty);
|
||||||
}
|
}
|
||||||
@@ -33,13 +34,4 @@ public class FacultyManager implements Serializable {
|
|||||||
public List<Faculty> getFaculties() {
|
public List<Faculty> getFaculties() {
|
||||||
return faculties;
|
return faculties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFacultiesText() {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (Faculty fc : faculties)
|
|
||||||
builder.append(fc.getName()).append("\n");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,17 +33,7 @@ public class GroupManager implements Serializable {
|
|||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupsText() {
|
public StudentManager getSm() {
|
||||||
StringBuilder builder = new StringBuilder();
|
return sm;
|
||||||
for (Group gr : groups)
|
|
||||||
builder.append(gr.getName()).append("\n");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Group findGroup(String name) {
|
|
||||||
for (Group gr : groups) {
|
|
||||||
if (gr.getName().equals(name)) return gr;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package org.lumijiez.managers;
|
package org.lumijiez.managers;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.base.Grade;
|
import org.lumijiez.base.Grade;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.util.NameSurnameGroup;
|
import org.lumijiez.util.FullStudentData;
|
||||||
import org.lumijiez.base.Student;
|
import org.lumijiez.base.Student;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -11,12 +12,12 @@ public class Supervisor implements Serializable {
|
|||||||
private final FacultyManager fm;
|
private final FacultyManager fm;
|
||||||
|
|
||||||
public Supervisor() {
|
public Supervisor() {
|
||||||
this.groupManager = new FacultyManager();
|
this.fm = new FacultyManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStudentsText() {
|
public String getStudentsText() {
|
||||||
StringBuilder info = new StringBuilder();
|
StringBuilder info = new StringBuilder();
|
||||||
for (Group group : groupManager.getGroups()) {
|
for (Group group : fm.getGm().getGroups()) {
|
||||||
for (Student student : group.getStudents()) {
|
for (Student student : group.getStudents()) {
|
||||||
info.append(student.getFullname()).append(" ").append(student.getGroup().getName()).append("\n");
|
info.append(student.getFullname()).append(" ").append(student.getGroup().getName()).append("\n");
|
||||||
}
|
}
|
||||||
@@ -24,27 +25,46 @@ public class Supervisor implements Serializable {
|
|||||||
return info.toString();
|
return info.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGradesText(NameSurnameGroup NSG) {
|
public String getGradesText(FullStudentData data) {
|
||||||
StringBuilder info = new StringBuilder();
|
StringBuilder info = new StringBuilder();
|
||||||
for (Grade grade : groupManager.getGroup(NSG.group()).getStudent(NSG.name(), NSG.surname()).getGrades()) {
|
for (Grade gr : fm.getGm().getSm().getStudent(data).getGrades()) {
|
||||||
info.append(grade.getSubject()).append(" ").append(grade.getGrade());
|
info.append(gr.getSubject()).append(" ").append(gr.getGrade());
|
||||||
}
|
}
|
||||||
return info.toString();
|
return info.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeGroup(NameSurnameGroup NSG, String groupName) {
|
public String getGroupsText() {
|
||||||
Group gr = groupManager.findGroup(groupName);
|
StringBuilder builder = new StringBuilder();
|
||||||
groupManager.getGroup(groupName).getStudent(NSG.name(), NSG.surname()).setGroup(gr);
|
for (Group gr : fm.getGm().getGroups())
|
||||||
|
builder.append(gr.getName()).append("\n");
|
||||||
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStudent(NameSurnameGroup NSG) {
|
public String getFacultiesText() {
|
||||||
Group currentGroup = groupManager.getGroup(NSG.group());
|
StringBuilder builder = new StringBuilder();
|
||||||
currentGroup.addStudent(new Student(NSG.name(), NSG.surname(), currentGroup));
|
for (Faculty fc : fm.getFaculties())
|
||||||
|
builder.append(fc.getName()).append("\n");
|
||||||
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGrade(NameSurnameGroup NSG, Grade grade) {
|
public FacultyManager getFm() {
|
||||||
Student student = groupManager.getGroup(NSG.group()).getStudent(NSG.name(), NSG.surname());
|
return fm;
|
||||||
student.addGrade(grade);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public void changeGroup(NameSurnameGroup NSG, String groupName) {
|
||||||
|
// Group gr = groupManager.findGroup(groupName);
|
||||||
|
// groupManager.getGroup(groupName).getStudent(NSG.name(), NSG.surname()).setGroup(gr);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public void addStudent(NameSurnameGroup NSG) {
|
||||||
|
// Group currentGroup = groupManager.getGroup(NSG.group());
|
||||||
|
// currentGroup.addStudent(new Student(NSG.name(), NSG.surname(), currentGroup));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public void addGrade(NameSurnameGroup NSG, Grade grade) {
|
||||||
|
// Student student = groupManager.getGroup(NSG.group()).getStudent(NSG.name(), NSG.surname());
|
||||||
|
// student.addGrade(grade);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.lumijiez.util;
|
package org.lumijiez.util;
|
||||||
|
|
||||||
|
|
||||||
import org.lumijiez.base.Faculty;package org.lumijiez.util;
|
import org.lumijiez.base.Faculty;
|
||||||
|
|
||||||
// Helper class for easier management of names, surnames, and groups
|
// Helper class for easier management of names, surnames, and groups
|
||||||
public class FullStudentData {
|
public class FullStudentData {
|
||||||
@@ -33,4 +33,11 @@ public class FullStudentData {
|
|||||||
public String faculty() {
|
public String faculty() {
|
||||||
return facultyName;
|
return facultyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(FullStudentData data) {
|
||||||
|
return this.name.equals(data.name())
|
||||||
|
&& this.surname.equals(data.surname())
|
||||||
|
&& this.groupName.equals(data.group())
|
||||||
|
&& this.facultyName.equals(data.faculty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package org.lumijiez.util;
|
|
||||||
|
|
||||||
// Helper class for easier management of names, surnames, and groups
|
|
||||||
public class NameSurnameGroup {
|
|
||||||
private final String name;
|
|
||||||
private final String surname;
|
|
||||||
private final String groupName;
|
|
||||||
|
|
||||||
public NameSurnameGroup(String name, String surname, String groupName) {
|
|
||||||
this.name = name;
|
|
||||||
this.surname = surname;
|
|
||||||
this.groupName = groupName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String surname() {
|
|
||||||
return surname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String group() {
|
|
||||||
return groupName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user