Update src/main/java/models/Course.java
This commit is contained in:
@@ -37,14 +37,15 @@ public class Course {
|
||||
return students;
|
||||
}
|
||||
|
||||
public void showStudents() {
|
||||
public String getStudentsDisplay() {
|
||||
if (students.isEmpty()) {
|
||||
System.out.println(" No students enrolled yet.");
|
||||
return " No students enrolled yet.";
|
||||
} else {
|
||||
System.out.println(" Students in " + name + ":");
|
||||
StringBuilder sb = new StringBuilder(" Students in " + name + ":\n");
|
||||
for (Student s : students) {
|
||||
System.out.println(" - " + s.getUsername());
|
||||
sb.append(" - ").append(s.getUsername()).append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user