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

41 lines
723 B
Java
Raw Normal View History

2016-03-06 08:05:32 +00:00
package com.bytezone.diskbrowser.visicalc;
2016-03-12 22:38:03 +00:00
class Max extends Function
2016-03-06 08:05:32 +00:00
{
2016-03-12 02:21:00 +00:00
private final Range range;
2016-03-06 08:05:32 +00:00
public Max (Sheet parent, String text)
{
2016-03-09 10:38:53 +00:00
super (parent, text);
2016-03-07 12:16:11 +00:00
range = getRange (text);
2016-03-06 08:05:32 +00:00
}
2016-03-12 02:21:00 +00:00
@Override
2016-03-16 06:15:39 +00:00
public void calculate ()
2016-03-12 02:21:00 +00:00
{
2016-03-16 06:15:39 +00:00
value = Double.MIN_VALUE;
isError = false;
int totalChecked = 0;
2016-03-12 05:05:50 +00:00
2016-03-06 08:05:32 +00:00
for (Address address : range)
{
2016-03-12 02:21:00 +00:00
Cell cell = parent.getCell (address);
2016-03-16 06:15:39 +00:00
if (cell == null)
continue;
if (cell.isError () || cell.isNaN ())
2016-03-12 02:21:00 +00:00
{
2016-03-16 06:15:39 +00:00
isError = true;
break;
2016-03-12 02:21:00 +00:00
}
2016-03-16 06:15:39 +00:00
double temp = cell.getValue ();
if (temp > value)
value = temp;
totalChecked++;
2016-03-06 08:05:32 +00:00
}
2016-03-16 06:15:39 +00:00
if (totalChecked == 0)
isError = true;
2016-03-06 08:05:32 +00:00
}
}