mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-09-25 10:55:45 +00:00
39 lines
938 B
Java
39 lines
938 B
Java
package com.bytezone.diskbrowser.visicalc;
|
|
|
|
class If extends Function
|
|
{
|
|
private final Condition condition;
|
|
private final String textTrue;
|
|
private final String textFalse;
|
|
|
|
private Expression expTrue;
|
|
private Expression expFalse;
|
|
|
|
public If (Sheet parent, String text)
|
|
{
|
|
super (parent, text);
|
|
|
|
int pos1 = functionText.indexOf (',');
|
|
int pos2 = functionText.indexOf (',', pos1 + 1);
|
|
condition = new Condition (parent, functionText.substring (0, pos1));
|
|
textTrue = functionText.substring (pos1 + 1, pos2);
|
|
textFalse = functionText.substring (pos2 + 1);
|
|
}
|
|
|
|
@Override
|
|
public double getValue ()
|
|
{
|
|
if (condition.getResult ())
|
|
{
|
|
if (expTrue == null)
|
|
expTrue = new Expression (parent, textTrue);
|
|
return expTrue.getValue ();
|
|
}
|
|
else
|
|
{
|
|
if (expFalse == null)
|
|
expFalse = new Expression (parent, textFalse);
|
|
return expFalse.getValue ();
|
|
}
|
|
}
|
|
} |