/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ /** * * @author Uwe Schmidt * * # der Elemente in einem Container * arbeitet wie IntegerSum * */ //-------------------- public class NoOfElements extends Accumulate { //-------------------- // die Resultat Variable // in der das Ergebnis akkumuliert wird private int result; //-------------------- public NoOfElements() { result = 0; } //-------------------- public void process(Object element) { ++result; } //-------------------- public Object getResult() { // Konversion int --> Objekt return new Integer(result); } }