Update src/main/java/models/Teacher.java
This commit is contained in:
@@ -32,22 +32,26 @@ public class Teacher extends User {
|
|||||||
return myCourses;
|
return myCourses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showMyCourses() {
|
public String getMyCoursesDisplay() {
|
||||||
if (myCourses.isEmpty()) {
|
if (myCourses.isEmpty()) {
|
||||||
System.out.println(" You don't teach any course yet.");
|
return " You don't teach any course yet.";
|
||||||
} else {
|
} else {
|
||||||
System.out.println("\n My Courses:");
|
StringBuilder sb = new StringBuilder("\n My Courses:\n");
|
||||||
for (int i = 0; i < myCourses.size(); i++) {
|
for (int i = 0; i < myCourses.size(); i++) {
|
||||||
System.out.println(" " + (i+1) + ". " + myCourses.get(i));
|
sb.append(" ").append(i+1).append(". ").append(myCourses.get(i)).append("\n");
|
||||||
}
|
}
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showStudentsInCourse(Course course) {
|
public boolean checkCourseOwnership(Course course) {
|
||||||
|
return myCourses.contains(course);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStudentsDisplayForCourse(Course course) {
|
||||||
if (!myCourses.contains(course)) {
|
if (!myCourses.contains(course)) {
|
||||||
System.out.println(" You don't teach this course!");
|
return "You don't teach this course!";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
course.showStudents();
|
return course.getStudentsDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user