Class LightComparator
java.lang.Object
SensorComparator
LightComparator
- All Implemented Interfaces:
- java.util.Comparator<FinchSensor>
public class LightComparator
- extends SensorComparator
Provides a Comparator implementation for the combined light sensors. By
"combined" we mean that we are implementing a "virtual" sensor that has a value
that is the sum of the real left and right sensors.
DO NOT INCLUDE AUTHOR NAMES IN SOURCE FILE
Method Summary |
int |
compare(FinchSensor obj1,
FinchSensor obj2)
Compare two FinchSensor objects: light sensor |
double |
doubleValue(FinchSensor obj)
Return the value of obj that is specified by the instantiation of the child
class. |
java.lang.String |
toString()
Force the child class to return a string that describes itself. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
LightComparator
public LightComparator()
compare
public int compare(FinchSensor obj1,
FinchSensor obj2)
- Compare two FinchSensor objects: light sensor
- Parameters:
obj1
- FinchSensor objectobj2
- FinchSensor object
- Returns:
- 1 if obj1 is larger than obj2, 0 if they are equal and -1 if obj1 is less than obj1
doubleValue
public double doubleValue(FinchSensor obj)
- Description copied from class:
SensorComparator
- Return the value of obj that is specified by the instantiation of the child
class.
- Specified by:
doubleValue
in class SensorComparator
- Parameters:
obj
- A FinchSensor sample
- Returns:
- The value of the "virtual" sensor as a double
toString
public java.lang.String toString()
- Description copied from class:
SensorComparator
- Force the child class to return a string that describes itself.
- Specified by:
toString
in class SensorComparator
- Returns:
- A string describing this comparator