develop #2
@@ -37,14 +37,15 @@ public class Course {
|
|||||||
return students;
|
return students;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showStudents() {
|
public String getStudentsDisplay() {
|
||||||
if (students.isEmpty()) {
|
if (students.isEmpty()) {
|
||||||
System.out.println(" No students enrolled yet.");
|
return " No students enrolled yet.";
|
||||||
} else {
|
} else {
|
||||||
System.out.println(" Students in " + name + ":");
|
StringBuilder sb = new StringBuilder(" Students in " + name + ":\n");
|
||||||
for (Student s : students) {
|
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