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

42 lines
686 B
Java
Raw Normal View History

2016-03-10 09:21:47 +00:00
package com.bytezone.diskbrowser.visicalc;
2016-03-12 22:38:03 +00:00
class And extends Function
2016-03-10 09:21:47 +00:00
{
2017-03-19 03:49:14 +00:00
private final ConditionList conditions;
2016-03-10 09:21:47 +00:00
public And (Cell cell, String text)
2016-03-10 09:21:47 +00:00
{
super (cell, text);
2017-03-03 23:41:08 +00:00
2017-03-18 09:21:11 +00:00
assert text.startsWith ("@AND(") : text;
2017-03-19 03:49:14 +00:00
conditions = new ConditionList (cell, functionText);
2016-03-10 09:21:47 +00:00
}
@Override
2017-02-28 20:39:26 +00:00
public void calculate ()
2016-03-10 09:21:47 +00:00
{
2017-02-25 03:56:22 +00:00
for (Condition condition : conditions)
2017-02-26 10:44:10 +00:00
{
condition.calculate ();
if (condition.getValue () == 0)
2017-02-25 03:56:22 +00:00
{
value = 0;
2017-02-28 20:39:26 +00:00
return;
2017-02-25 03:56:22 +00:00
}
2017-02-26 10:44:10 +00:00
}
2017-02-25 03:56:22 +00:00
value = 1;
2016-03-10 09:21:47 +00:00
}
2017-03-18 00:24:05 +00:00
@Override
public boolean isBoolean ()
{
return true;
}
@Override
public String getText ()
{
return value == 0 ? "FALSE" : "TRUE";
}
2016-03-10 09:21:47 +00:00
}