Object Interaction

Programming Paradigms

The ability to ignore details of parts to focus attention on a higher level of a problem
The process of dividing a whole into well-defined parts, which can be built and examined separately, and which interact in well-defined ways

A class can have within it other classes

public class NumberDisplay
    private int limit;
    private int value;

public class ClockDisplay
private NumberDisplay hours;
private NumberDisplay minutes;

The variables in NumberDisplay are primitive types

The variables in ClockDisplay are object types

Objects creating objects

Formal parameter:

public NumberDisplay(int rollOverLimit);

Actual Parameter:

hours = new NumberDisplay(24);

Method calling

public void timeTick()
    if(minutes.getValue() == 0) {
        // it just rolled over!

Internal Methods

* Update the internal string that
* represents the display.
private void updateDisplay()
    displayString =
    hours.getDisplayValue() + ":" +

Method calls

Internal method calls

private void updateDisplay()

External method calls