|
Building Parsers with Java | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--sjm.examples.design.RunningAverage
Objects of this class maintain a running average. Each
number that is added with the add method
increases the count by 1, and the total by the amount
added.
| Field Summary | |
protected double |
count
|
protected double |
total
|
| Constructor Summary | |
RunningAverage()
|
|
| Method Summary | |
void |
add(double d)
Add a value to the running average, increasing the count by 1 and the total by the given value. |
double |
average()
Return the average so far. |
java.lang.Object |
clone()
Return a copy of this object. |
| Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected double count
protected double total
| Constructor Detail |
public RunningAverage()
| Method Detail |
public void add(double d)
double - the value to add into the running averagepublic double average()
public java.lang.Object clone()
|
by Steve Metsker | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||