OO Programming with Java


Exercice (cont.)

Another example of an application is given here

package organization;

public class Demo {
  public static void main(String[] args) {
    NamedElement ne1 = new Person("John");
    NamedElement ne2 = new Person("Bill");
    NamedElement ne3 = new Person("Kate");
    Group a1  = new Group("1A");
    Group ase = new Group("ASE");
    Group ir  = new Group("IR");
    a1.add(ase); a1.add(ir);
    ase.add(ne1); ase.add(ne2); ir.add(ne3);
    System.out.println( a1 );
  }
}

14 - 14