pnuts.ext
Class UnitSystem

java.lang.Object
  |
  +--pnuts.ext.UnitSystem

public class UnitSystem
extends java.lang.Object
implements QuantityFactory, java.io.Serializable

This class defines a unit system in Pnuts. When an identifier follows a decimal number, the identifier should be one of the units symbols defined.

 UnitSystem(["cm", "m"], [1, 100])
 1cm + 1m  ==> 101.000cm
 

See Also:
Serialized Form

Constructor Summary
UnitSystem(java.lang.String[] units, java.lang.Number[] scale)
           
 
Method Summary
 void init()
           
 java.lang.Object make(java.lang.Number n, java.lang.String unit)
           
 void setPrecision(int prec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnitSystem

public UnitSystem(java.lang.String[] units,
                  java.lang.Number[] scale)
Method Detail

init

public void init()

setPrecision

public void setPrecision(int prec)

make

public java.lang.Object make(java.lang.Number n,
                             java.lang.String unit)
Specified by:
make in interface QuantityFactory