Quote:
Originally Posted by notmattlythgoe
GeeTwo, it works because getDistance() returns an object not a value. So the getValue() call on the object at the time of the comparison will get the current value.
|
OK, my poorly exercised OO brain gets it, but my better exercised procedural brain sees spooky action at a getDistance().
That suggests to me that you would want to have polymorphic forms of the command, including one which allows
both operands to be objects. This could then be used to do things like (for example) returning the original drive direction by driving faster with the left wheel than the right, then equalizing after a
Code:
waitUntil(leftAxle.getDistance(), GREATER_THAN_EQUAL, rightAxle.getDistance())
completes. If you do this, you should allow either operand or both to be objects. For sanity's sake, a constructor using two numeric values could be created, but it should throw an exception telling the user that [s]he is trying to wait forever, or not at all.