All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ggp.base.apps.research.Counter Maven / Gradle / Ivy

The newest version!
package org.ggp.base.apps.research;

/**
 * Counter is a convenience class for tracking a count.
 *
 * @author Sam Schreiber
 */
public final class Counter implements Comparable
{
    private double totalValue = 0;

    public void addValue(double value) {
        totalValue += value;
    }

    public double getValue() {
        return totalValue;
    }

    @Override
    public String toString() {
        return "" + ((int)(getValue() * 1000.0)/1000.0);
    }

    @Override
    public int compareTo(Counter arg0) {
        return (int)Math.signum(getValue() - arg0.getValue());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy