created ValueListFunction

This commit is contained in:
Denis Molony 2017-03-20 10:33:23 +11:00
parent 36750a11e7
commit db13c5c256
10 changed files with 27 additions and 66 deletions

View File

@ -2,21 +2,12 @@ package com.bytezone.diskbrowser.visicalc;
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
public class Average extends Function
public class Average extends ValueListFunction
{
private final boolean isRange; // may affect how the count is done
public Average (Cell cell, String text)
{
super (cell, text);
assert text.startsWith ("@AVERAGE(") : text;
list = new ValueList (cell, functionText);
isRange = functionText.indexOf ("...") > 0;
for (Value v : list)
values.add (v);
}
@Override

View File

@ -2,19 +2,12 @@ package com.bytezone.diskbrowser.visicalc;
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
public class Choose extends Function
public class Choose extends ValueListFunction
{
Choose (Cell cell, String text)
{
super (cell, text);
assert text.startsWith ("@CHOOSE(") : text;
// parameters are a Value, followed by a Range
list = new ValueList (cell, functionText);
for (Value v : list)
values.add (v);
}
@Override

View File

@ -2,21 +2,12 @@ package com.bytezone.diskbrowser.visicalc;
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
class Count extends Function
class Count extends ValueListFunction
{
private final boolean isRange;
public Count (Cell cell, String text)
{
super (cell, text);
assert text.startsWith ("@COUNT(") : text;
list = new ValueList (cell, functionText);
isRange = functionText.indexOf ("...") > 0;
for (Value v : list)
values.add (v);
}
@Override

View File

@ -17,7 +17,6 @@ abstract class Function extends AbstractValue implements Iterable<Value>
protected String fullText;
protected Value source;
protected ValueList list;
protected Range range;
Function (Cell cell, String text)

View File

@ -1,18 +1,11 @@
package com.bytezone.diskbrowser.visicalc;
class Lookup extends Function
class Lookup extends ValueListFunction
{
public Lookup (Cell cell, String text)
{
super (cell, text);
assert text.startsWith ("@LOOKUP(") : text;
// parameters are a Value, followed by a Range
list = new ValueList (cell, functionText);
for (Value v : list)
values.add (v);
}
@Override

View File

@ -1,17 +1,11 @@
package com.bytezone.diskbrowser.visicalc;
class Max extends Function
class Max extends ValueListFunction
{
public Max (Cell cell, String text)
{
super (cell, text);
assert text.startsWith ("@MAX(") : text;
list = new ValueList (cell, functionText);
for (Value v : list)
values.add (v);
}
@Override

View File

@ -1,17 +1,11 @@
package com.bytezone.diskbrowser.visicalc;
class Min extends Function
class Min extends ValueListFunction
{
public Min (Cell cell, String text)
{
super (cell, text);
assert text.startsWith ("@MIN(") : text;
list = new ValueList (cell, functionText);
for (Value v : list)
values.add (v);
}
@Override

View File

@ -2,19 +2,12 @@ package com.bytezone.diskbrowser.visicalc;
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
public class Npv extends Function
public class Npv extends ValueListFunction
{
Npv (Cell cell, String text)
{
super (cell, text);
assert text.startsWith ("@NPV(") : text;
// parameters are a Value, followed by a Range
list = new ValueList (cell, functionText);
for (Value v : list)
values.add (v);
}
@Override

View File

@ -1,17 +1,11 @@
package com.bytezone.diskbrowser.visicalc;
class Sum extends Function
class Sum extends ValueListFunction
{
public Sum (Cell cell, String text)
{
super (cell, text);
assert text.startsWith ("@SUM(") : text;
list = new ValueList (cell, functionText);
for (Value v : list)
values.add (v);
}
@Override

View File

@ -0,0 +1,19 @@
package com.bytezone.diskbrowser.visicalc;
public abstract class ValueListFunction extends Function
{
protected final ValueList list;
protected final boolean isRange;
public ValueListFunction (Cell cell, String text)
{
super (cell, text);
list = new ValueList (cell, functionText);
isRange = functionText.indexOf ("...") > 0;
for (Value v : list)
values.add (v);
}
}