This commit is contained in:
2026-07-11 17:56:02 +04:30
parent a5e1b6ebb0
commit e34965a81a
2 changed files with 43 additions and 4 deletions
+16 -1
View File
@@ -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;
}
}
+27 -3
View File
@@ -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;
}