package
gve.calc.formula;
import
java.awt.*;
@version 28 Sep 1997 @author Geert Vernaeve
public
class
Interval
extends
Part
{
public
double
low,high;
public
boolean
openLow,openHigh;
public
Interval
(
double
l,
double
h,
boolean
openL,
boolean
openH) {
if
(l < h) { low = l; high = h; openLow = openL; openHigh = openH; }
else
{ low = h; high = l; openLow = openH; openHigh = openL; } }
public
Object clone() {
if
(low == high)
return
new
Real
(low);
return
new
Interval
(low,high,openLow,openHigh); }
An Interval can be equal to a Real if it is of type [a,a]
public
boolean
equals(Object obj) {
if
(low==high && obj
instanceof
Real
)
if
(!openLow && !openHigh && ((
Real
)obj).doubleValue == low)
return
true;
if
(!(obj
instanceof
Interval
))
return
false;
return
((
Interval
)obj).low==low && ((
Interval
)obj).high==high && ((
Interval
)obj).openLow==openLow && ((
Interval
)obj).openHigh==openHigh; }
public
Part
evaluate(
Evaluator
ev) {
return
(
Part
)clone(); }
public
String toString() {
return
"Interval "
+ (openLow?
']'
:
'['
) + low +
","
+ high + (openHigh?
'['
:
']'
); } }