dmolony-DiskBrowser/src/com/bytezone/diskbrowser/visicalc/Sum.java

40 lines
1.1 KiB
Java

package com.bytezone.diskbrowser.visicalc;
// -----------------------------------------------------------------------------------//
class Sum extends ValueListFunction
// -----------------------------------------------------------------------------------//
{
// ---------------------------------------------------------------------------------//
Sum (Cell cell, String text)
// ---------------------------------------------------------------------------------//
{
super (cell, text);
assert text.startsWith ("@SUM(") : text;
}
// ---------------------------------------------------------------------------------//
@Override
public void calculate ()
// ---------------------------------------------------------------------------------//
{
value = 0;
valueResult = ValueResult.VALID;
for (Value v : list)
{
v.calculate ();
if (v.getValueResult () == ValueResult.NA)
continue;
if (!v.isValid ())
{
valueResult = v.getValueResult ();
return;
}
value += v.getDouble ();
}
}
}