jasi.sim.geo.cartesian
Class Speed

java.lang.Object
  extended by jasi.sim.basic.value.AbstractSimValueType
      extended by jasi.sim.basic.value.AbstractComparableObject<T>
          extended by jasi.sim.geo.ComparableGeoObject<Speed>
              extended by jasi.sim.geo.cartesian.Speed
All Implemented Interfaces:
ExtendedComparable<Speed>, SimValue, Geometric, java.io.Serializable, java.lang.Comparable<Speed>

public final class Speed
extends ComparableGeoObject<Speed>

Immutable class to represent speed values.

See Also:
Serialized Form

Field Summary
static java.util.Comparator<Speed> COMPARATOR
          Compare the values of speed objects.
static Speed FIXED
          Non-moving, fixed.
static Speed KM_H
          Speed constant for a kilometer per hour.
static Speed KM_S
          Speed constant for a kilometer per second.
static Speed M_S
          Speed constant for meter per second.
 
Fields inherited from interface jasi.sim.geo.Geometric
BEGIN, END, MIDLE
 
Constructor Summary
Speed(Speed s)
          Constructor of a speed value.
Speed(java.lang.String s)
          Constructor of a speed value.
 
Method Summary
 Speed add(Speed s)
          Add that speed to this speed.
 double amount(Speed s)
          Retrieve the amount of this speed value in units of that speed.
 int compareTo(Speed s)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object o)
          Indicates whether some other object is "equal to" this one.
 int hashCode()
          Returns a hash code value for the object.
 Speed minus(Speed s)
          Subtract that speed from this speed.
 Space spaceFor(Time t)
          Returns the distance moved by this speed in a given time.
 Time timeFor(Space d)
          Returns the time needed to move a given distance by this speed.
 Speed times(double f)
          Multiply this Speed object by a factor.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class jasi.sim.basic.value.AbstractComparableObject
isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class jasi.sim.basic.value.AbstractSimValueType
getContent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jasi.sim.basic.value.SimValue
getContent
 

Field Detail

COMPARATOR

public static final java.util.Comparator<Speed> COMPARATOR
Compare the values of speed objects. Difference function, which imposes a total ordering.


M_S

public static final Speed M_S
Speed constant for meter per second.


KM_S

public static final Speed KM_S
Speed constant for a kilometer per second.


KM_H

public static final Speed KM_H
Speed constant for a kilometer per hour.


FIXED

public static final Speed FIXED
Non-moving, fixed.

Constructor Detail

Speed

public Speed(Speed s)
Constructor of a speed value.

Parameters:
s - A speed value.

Speed

public Speed(java.lang.String s)
Constructor of a speed value.

Parameters:
s - The string representation of a speed value.
Method Detail

amount

public double amount(Speed s)
Retrieve the amount of this speed value in units of that speed.

Parameters:
s - That speed object.
Returns:
The amount.

add

public Speed add(Speed s)
Add that speed to this speed.

Parameters:
s - That speed.
Returns:
The new speed.

minus

public Speed minus(Speed s)
Subtract that speed from this speed.

Parameters:
s - That speed.
Returns:
The new speed.

times

public Speed times(double f)
Multiply this Speed object by a factor.

Parameters:
f - The multiplication factor.
Returns:
The new Speed.

timeFor

public Time timeFor(Space d)
Returns the time needed to move a given distance by this speed.

Parameters:
d - That distance.
Returns:
The time.

spaceFor

public Space spaceFor(Time t)
Returns the distance moved by this speed in a given time.

Parameters:
t - That time.
Returns:
The distance

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The string.

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hash tables.

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for this object.

equals

public boolean equals(java.lang.Object o)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class java.lang.Object
Parameters:
o - That object which is compared with this object.
Returns:
True, if this object is the same as that object.

compareTo

public int compareTo(Speed s)
Compares this object with the specified object for order. Implementation of java.lang.Comparable interface.

Specified by:
compareTo in interface java.lang.Comparable<Speed>
Specified by:
compareTo in class AbstractComparableObject<Speed>
Parameters:
s - The speed to be compared.
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than that object.
See Also:
Comparable.compareTo(Object)