Back home
Constrained variable
Object
subclass: #ConstrainedVariable
instanceVariableNames: 'name domain'
classVariableNames: ''
poolDictionaries: ''
!ConstrainedVariable class methods!
constructEventsTriggered
"Private - answer the set of events that instances of the
receiver can trigger."
^#(#min #max) asSet
from: aMin to: aMax
^super new from: aMin to: aMax
!ConstrainedVariable methods!
* y
| c |
c := ActTimes x: self y: y.
^c result "a constrained variable"
+ y
|c|
c := ActAdd x: self y: y.
^c result "a constrained variable"
@= y
|c|
c := ActEquals x: self y: y.
^c result " a constrained variable
domain
^domain!
domain: anObject
domain := anObject!
max
^domain last!
max: aValue
domain newMax: aValue.
self triggerEvent: #max!
min
^domain first!
min: aValue
domain newMin: aValue.
self triggerEvent: #min!
printOn: aStream
aStream nextPutAll: name, ' ',domain printString! !
from: aMin to: aMax
domain := Interval from: aMin to: aMax.