public static void main(String[] args) { // TODO Auto-generated method stub Person p1 = new Person("A"); Person p2 = new Person("B", "shanghai"); Student s1 = new Student("C", "S1"); Student s2 = new Student("C", "shanghai", "S2"); System.out.println(p1.info()); System.out.println(p2.info()); System.out.println(s1.info()); System.out.println(s2.info()); // Student tom = new Student("tom", "haidianyizhong"); // tom.info(); // Student allen = new Student("allen", "fujian", "fuzhousanzhong"); // allen.info(); }
public void addStudent(Student student) { for (int i = 0; i < groupSize + 1; i++) { try { if (group[i] == null) { group[i] = student; System.out.println("Student added to group: " + student.info()); return; } } catch (ArrayIndexOutOfBoundsException e) { throw new GroupException(); } } }
public static void main(String[] args) { Student s = new Student("홍길동", 1, 1, 100, 60, 76); System.out.println(s.info()); }