codesimian
Class Fuel

java.lang.Object
  extended by codesimian.CS
      extended by codesimian.IndependentCS
          extended by codesimian.Fuel
All Implemented Interfaces:
CodeSimian

public final class Fuel
extends IndependentCS

Fuel is unusual because it is only 1-way (instead of 2-way) interchangable with other subclasses of CS. That is necessary to enforce the following:

(1) Only

(2) You can not create or destroy Fuel, but you can lose it (by garbage-collection).

(3) You can combine Fuels into a single Fuel of the same value (leaving 1 with 0 value) or split Fuel into multiple Fuels totaling the same value, or partially divide or combine, but the total fuel must remain constant for the whole execution of this java program.

If any Java object or function has a reference to your Fuel, they can take some or all of it any time they want.

WARNING: It is theoretically possible to intentionally and repeatedly use ROUNDOFF ERROR to increase the total money supply, but double precision (64 bit) makes it impractical to counterfeit a useful amount.

Fuel extends IndependentCS but should it instead extend N which extends DefaultCS? Only if DefaultCS is fixed to use less memory per instance. Theres approximately 8 instance vars and there should be only 4. (Remove the Object variable. Subclasses can define a more specific type of variable.)


Field Summary
 
Fields inherited from class codesimian.CS
DESCRIPTION, END, EXECPROXY, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER, THIS
 
Method Summary
 void add(Fuel m, double amountOfM)
          transfers all or a fraction of an other Fuel's value to this Fuel's value
 void addAll(Fuel m)
          adds m to my value and makes m worthless
static Fuel createTheFirstFuel(double amount)
          to avoid counterfeiters, this only works the first call, any amount.
 boolean isZero()
           
 Fuel remove(double amount)
          splits this Fuel into itself (with amount removed) and a new Fuel of specified value
 Fuel removeAll()
           
 java.lang.String toString()
          independentCS.countP() should always be 0.
 double value()
          how much is this Fuel worth?
 
Methods inherited from class codesimian.IndependentCS
B, BForProxy, C, CForProxy, countP, D, decrementMyFuel, deleteP, description, DForProxy, F, FForProxy, fuel, getExec, heap, I, IForProxy, insertD, insertL, insertL, insertL1, insertP, J, JForProxy, keyword, L, L, LForProxy, LForProxy, maxP, minP, myFuel, name, newInstance, P, parent, prevD, prevL, PType, S, setD, setD, setFuel, setL, setL, setL, setL1, setMyFuel, setP, setPrevExec, SForProxy, V, VForProxy, Z, ZForProxy
 
Methods inherited from class codesimian.CS
addB, addC, addD, addF, addI, addJ, addL, addP, addP, addP, addP, addP, addS, addZ, clone, cost, deleteP, GETB, GETC, GETD, GETF, GETI, GETJ, GETL, getObject, GETS, GETZ, indexP, indexPName, insertB, insertC, insertF, insertI, insertJ, insertS, insertZ, isIllusion, L, L, L, maxD, minD, overwrites, parsePriority, PB, PC, PD, PF, PI, PJ, PL, prevB, prevC, prevF, prevI, prevJ, prevS, prevZ, proxyOf, PS, PZ, reflect, reflect, reflect6, setB, SETB, setB, setC, SETC, setC, setCost, SETD, setDescription, setExec, setF, SETF, setF, setHeap, setI, SETI, setI, setJ, setJ, SETJ, SETL, setL, setL, setName, setObject, setParent, setParsePriority, setProxyOf, setPType, setS, setS, SETS, setTester, setZ, SETZ, setZ, tester, toJavaCode, voidReflect
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

value

public double value()
how much is this Fuel worth?


isZero

public boolean isZero()

addAll

public void addAll(Fuel m)
adds m to my value and makes m worthless


add

public void add(Fuel m,
                double amountOfM)
transfers all or a fraction of an other Fuel's value to this Fuel's value


remove

public Fuel remove(double amount)
splits this Fuel into itself (with amount removed) and a new Fuel of specified value


removeAll

public Fuel removeAll()

createTheFirstFuel

public static Fuel createTheFirstFuel(double amount)
to avoid counterfeiters, this only works the first call, any amount. Only an existing Fuel can create a new Fuel, except for the first call of createTheFirstFuel. The total fuel is constant for the whole execution of this java program.


toString

public java.lang.String toString()
Description copied from class: IndependentCS
independentCS.countP() should always be 0. If its more, the params still wont show here

Overrides:
toString in class IndependentCS