File: OnOffComposite.java

Project: Java Mark IV Coffee Maker

package org.onestepback.markiv.devices;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class OnOffComposite implements OnOffDevice {
  private List myDevices = new ArrayList();

  public void on() {
    for (Iterator it = myDevices.iterator(); it.hasNext();) {
      OnOffDevice dev = (OnOffDevice) it.next();
      dev.on();
    }
  }

  public void off() {
    for (Iterator it = myDevices.iterator(); it.hasNext();) {
      OnOffDevice dev = (OnOffDevice) it.next();
      dev.off();
    }
  }

  public void add(OnOffDevice dev) {
    myDevices.add(dev);
  }
}

Used by: Boiler CoffeeMakerFactory


[ Index ][ Presentation ]
Generated by [ source2html ]