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

38 lines
707 B
Java
Raw Normal View History

2016-03-06 08:05:32 +00:00
package com.bytezone.diskbrowser.visicalc;
2017-02-18 09:54:24 +00:00
class Min extends Function
2016-03-06 08:05:32 +00:00
{
public Min (Cell cell, String text)
2016-03-06 08:05:32 +00:00
{
super (cell, text);
2017-03-03 23:41:08 +00:00
2017-03-18 09:21:11 +00:00
assert text.startsWith ("@MIN(") : text;
2017-03-18 21:23:44 +00:00
list = new ValueList (cell, functionText);
for (Value v : list)
values.add (v);
2016-03-06 08:05:32 +00:00
}
2016-03-12 02:21:00 +00:00
@Override
2017-02-28 20:39:26 +00:00
public void calculate ()
2016-03-12 02:21:00 +00:00
{
2016-03-16 06:15:39 +00:00
value = Double.MAX_VALUE;
int totalChecked = 0;
2016-03-12 05:05:50 +00:00
2017-03-15 00:41:45 +00:00
for (Value v : list)
2016-03-06 08:05:32 +00:00
{
2017-03-15 00:41:45 +00:00
v.calculate ();
if (!v.isValueType (ValueType.VALUE))
2016-03-12 02:21:00 +00:00
{
2017-02-25 03:56:22 +00:00
valueType = cell.getValueType ();
2017-03-15 07:07:36 +00:00
return;
2016-03-12 02:21:00 +00:00
}
2016-03-16 06:15:39 +00:00
2017-03-15 07:07:36 +00:00
value = Math.min (value, v.getValue ());
2016-03-16 06:15:39 +00:00
totalChecked++;
2016-03-06 08:05:32 +00:00
}
2016-03-16 06:15:39 +00:00
2017-03-15 07:07:36 +00:00
valueType = totalChecked == 0 ? ValueType.NA : ValueType.VALUE;
2016-03-06 08:05:32 +00:00
}
}