You’re referring to the exercise (often in the AP CSA or Intro to Java track). The task usually involves creating a Teacher class and a ClassList class to store and manage teachers and their students.
public boolean addStudent(String studentName) { if (students.size() < teacher.getMaxClassSize()) { students.add(studentName); return true; } return false; } 7.2.8 Teacher Class List BEST
public class Main { public static void main(String[] args) { Teacher chen = new Teacher("Ms. Chen", "AP CSA", 5); ClassList compSci = new ClassList(chen); compSci.addStudent("Maya"); compSci.addStudent("Jordan"); compSci.addStudent("Sam"); compSci.addStudent("Taylor"); compSci.addStudent("Casey"); boolean added = compSci.addStudent("Alex"); // Should fail — max size 5 You’re referring to the exercise (often in the
compSci.printClassList(); System.out.println("Added Alex? " + added); } } When Ms. Chen runs the program, she sees: teacher.getMaxClassSize()) { students.add(studentName)
Verbinde dein Steam-Profil mit Keyforsteam
Drehe das Rad und gewinne Guthaben-Karten
Oder gewinne Punkte, um das Rad erneut zu drehen, um am Discord-Event teilzunehmen
Glücksgefühle? Gewinne eine PS5, Xbox Series X oder eine 500€ Amazon Geschenkkarte