OO Programming with Java


Abstraction

  1. As an illustration, a global program can be used to model groups of persons with subgroups with eventually capacity restriction:
public static void main(String[] args) {
  Person bill    = new Person("Bill Haris"); 
  Person amy     = new Person("Amy McCarty");
  Person john    = new Person("John Doe");
  Group sport    = new Group("Sport");
  Group tennis   = new RestrictedGroup("Tennis",10);
  Group football = new RestrictedGroup("Football",20);
  sport.add(tennis); sport.add(football);
  tennis.add(bill);  tennis.add(amy);
  football.add(amy); football.add(john);
  System.out.println( sport );
}

What leads to the following result:

+Sport
  +Tennis
    - Bill Haris
    - Amy McCarty
    (10)
  +Football
    - Amy McCarty
    - John Doe
    (20)

UML/SysML Objects' diagram

---
9 - 14