Update src/main/java/services/SchoolSystem.java
This commit is contained in:
@@ -16,7 +16,28 @@ public class SchoolSystem {
|
||||
}
|
||||
|
||||
// ========== Student Management ==========
|
||||
//TODO
|
||||
public boolean registerStudent(String username, String password) {
|
||||
if (findStudent(username) != null) {
|
||||
return false;
|
||||
}
|
||||
students.add(new Student(username, password));
|
||||
return true;
|
||||
}
|
||||
|
||||
public Student loginStudent(String username, String password) {
|
||||
Student student = findStudent(username);
|
||||
if (student != null && student.checkPassword(password)) {
|
||||
return student;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Student findStudent(String username) {
|
||||
for (Student s : students) {
|
||||
if (s.getUsername().equals(username)) return s;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ========== Teacher Management ==========
|
||||
public boolean registerTeacher(String username, String password) {
|
||||
@@ -44,12 +65,19 @@ public class SchoolSystem {
|
||||
|
||||
// ========== Course Management ==========
|
||||
public boolean addCourseToSystem(String courseName) {
|
||||
//TODO
|
||||
for (Course c : allCourses) {
|
||||
if (c.getName().equals(courseName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
allCourses.add(new Course(courseName));
|
||||
return true;
|
||||
}
|
||||
|
||||
public Course findCourseById(int id) {
|
||||
//TODO
|
||||
for (Course c : allCourses) {
|
||||
if (c.getId() == id) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user