Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e34965a81a |
@@ -11,5 +11,20 @@ public class Student extends User {
|
||||
this.enrolledCourses = new ArrayList<>();
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void enrollCourse(Course course) {
|
||||
this.enrolledCourses.add(course);
|
||||
}
|
||||
public void showMyCourses() {
|
||||
for (Course course : this.enrolledCourses) {
|
||||
System.out.println(course);
|
||||
}
|
||||
}
|
||||
public Course getEnrolledCourses(int id) {
|
||||
for (Course course : this.enrolledCourses) {
|
||||
if (course.getId() == id) {
|
||||
return course;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,26 @@ public class SchoolSystem {
|
||||
}
|
||||
|
||||
// ========== Student Management ==========
|
||||
//TODO
|
||||
public void registerStudent(String username, String password) {
|
||||
Student student = new Student(username, password);
|
||||
this.students.add(student);
|
||||
}
|
||||
public Student loginStudent(String username, String password) {
|
||||
for (Student student : this.students) {
|
||||
if (student.getUsername().equals(username) && student.checkPassword(password)) {
|
||||
return student;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private Student findStudent(String username) {
|
||||
for (Student student : this.students) {
|
||||
if (student.getUsername().equals(username)) {
|
||||
return student;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ========== Teacher Management ==========
|
||||
public boolean registerTeacher(String username, String password) {
|
||||
@@ -44,12 +63,17 @@ public class SchoolSystem {
|
||||
|
||||
// ========== Course Management ==========
|
||||
public boolean addCourseToSystem(String courseName) {
|
||||
//TODO
|
||||
Course course = new Course(courseName);
|
||||
this.allCourses.add(course);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Course findCourseById(int id) {
|
||||
//TODO
|
||||
for (Course course : this.allCourses) {
|
||||
if(course.getId() == id) {
|
||||
return course;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user