import java.util.ArrayList; import java.util.List; public class SchoolSystem { private List personList = new ArrayList<>(); // 统一的 addPerson 方法,替代原来的 addStudent / addTeacher public void addPerson(Person p) { personList.add(p); System.out.println("Added: " + p); } public void listAll() { System.out.println("\n--- All Members ---"); for (Person p : personList) { System.out.println(p); } } public static void main(String[] args) { SchoolSystem system = new SchoolSystem(); system.addPerson(new Student("Alice", 20, "S001", 3.8)); system.addPerson(new Student("Bob", 19, "S002", 3.5)); system.addPerson(new Teacher("Mr. Chen", 35, "Math", 10)); system.addPerson(new Teacher("Ms. Li", 28, "English", 4)); system.listAll(); } }