Class FinchSensor

java.lang.Object
  extended by FinchSensor
All Implemented Interfaces:
Comparable2

public class FinchSensor
extends java.lang.Object
implements Comparable2

Representation of a single sample of sensor values from the Finch. In particular, a sample contains:

Author:
Andrew H. Fagg and Steven Ness

Field Summary
private  double[] acceleration
          Holds the array of acceleration values
private  int[] light
          Holds the array of light values
private  boolean[] obstacle
          Holds the array of obstacle values
private  double temperature
          Holds the temperature value
 
Constructor Summary
FinchSensor(int[] light, double[] acceleration, boolean[] obstacle, double temperature)
          Primary constructor
 
Method Summary
private  int compareTo(double a, double b)
          Quick method used to compare doubles
private  int compareTo(int a, int b)
          Quick method used to compare integers a and b
 int compareTo2(java.lang.Object obj, VariableType var)
          Compare two objects based on a specific member variable (specified by parameter var)
 java.lang.String toString()
          Overriding the Object toString method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

light

private int[] light
Holds the array of light values


acceleration

private double[] acceleration
Holds the array of acceleration values


obstacle

private boolean[] obstacle
Holds the array of obstacle values


temperature

private double temperature
Holds the temperature value

Constructor Detail

FinchSensor

public FinchSensor(int[] light,
                   double[] acceleration,
                   boolean[] obstacle,
                   double temperature)
Primary constructor

Parameters:
light - 2-element array of light levels
acceleration - 3-element array of acceleration values
obstacle - 2-element array of obstacle values
temperature - Temperature
Method Detail

compareTo

private int compareTo(int a,
                      int b)
Quick method used to compare integers a and b

Parameters:
a -
b -
Returns:
1 if a is greater than b, -1 if the reverse is true, and 0 if they are equal

compareTo

private int compareTo(double a,
                      double b)
Quick method used to compare doubles

Parameters:
a -
b -
Returns:
1 if a is greater than b, -1 if the reverse is true, and 0 if they are equal

compareTo2

public int compareTo2(java.lang.Object obj,
                      VariableType var)
Compare two objects based on a specific member variable (specified by parameter var)

Specified by:
compareTo2 in interface Comparable2
Parameters:
obj - The passed object to compare against
var - The key to compare with
Returns:
1 if this.var > obj.var
0 if this.var == obj.var
and -1 if this.var < obj.var

toString

public java.lang.String toString()
Overriding the Object toString method

Overrides:
toString in class java.lang.Object
Returns:
A representation of this object as a String