uavsim.datatypes
Class Distance

java.lang.Object
  extended by uavsim.datatypes.Distance
All Implemented Interfaces:
java.lang.Comparable<Distance>, I_Unitable<Distance>

public class Distance
extends java.lang.Object
implements I_Unitable<Distance>

Defines a distance with arbitrary units. Given the constraints of the world, the valid interval is [0,999.99].

Author:
Dan Tappan [16.07.11]

Field Summary
private  double _distance
          the distance
private static double DISTANCE_MAX
          the maximum distance
private static double DISTANCE_MIN
          the minimum distance
 
Constructor Summary
Distance()
          Creates a distance object with a default value of zero.
Distance(double distance)
          Creates a distance object.
Distance(Radius radius)
          Creates a distance object.
 
Method Summary
 Distance add_(Distance distance)
          Adds another unit to this one.
 int compareTo(Distance distance)
          
 double getValue_()
          Returns the numerical value of this unit.
private  void setValue(double distance)
          Sets the distance
 Distance subtract_(Distance distance)
          Subtract another unit from this one.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_distance

private double _distance
the distance


DISTANCE_MAX

private static final double DISTANCE_MAX
the maximum distance

See Also:
Constant Field Values

DISTANCE_MIN

private static final double DISTANCE_MIN
the minimum distance

See Also:
Constant Field Values
Constructor Detail

Distance

public Distance()
Creates a distance object with a default value of zero.


Distance

public Distance(double distance)
Creates a distance object.

Parameters:
distance - - the distance

Distance

public Distance(Radius radius)
Creates a distance object.

Parameters:
radius - - the distance
Method Detail

add_

public Distance add_(Distance distance)
Adds another unit to this one. The result cannot exceed the limits [0,999.99].

Specified by:
add_ in interface I_Unitable<Distance>
Parameters:
distance - - the unit
Returns:
the result as a new unit

compareTo

public int compareTo(Distance distance)

Specified by:
compareTo in interface java.lang.Comparable<Distance>

getValue_

public double getValue_()
Returns the numerical value of this unit.

Specified by:
getValue_ in interface I_Unitable<Distance>
Returns:
the value

setValue

private void setValue(double distance)
Sets the distance

Parameters:
distance - - the distance

subtract_

public Distance subtract_(Distance distance)
Subtract another unit from this one. A negative result is illegal.

Specified by:
subtract_ in interface I_Unitable<Distance>
Parameters:
distance - - the unit
Returns:
the result as a new unit

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object