dLife Home Page

dlife.ga
Class Gene

java.lang.Object
  extended by dlife.ga.Gene
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
BitGene, DoubleGene, IntegerGene

public abstract class Gene
extends Object
implements Cloneable, Serializable

An abstract base class extended by all types of Genes. This defines the methods that must appear in any Gene used with the dlife.ga package. It also provides an implementation of the clone method that can be used by any Gene sub-class that contains only primitive and Cloneable fields.

Version:
Jan 6, 2007
Author:
Grant Braught, Dickinson College
See Also:
Serialized Form

Constructor Summary
Gene()
           
 
Method Summary
 Gene clone()
          Create a clone of this Gene.
 Gene copy()
          Generate an exact copy of this Gene.
abstract  boolean equals(Object obj)
          Determine if this Gene is equal to the Gene obj.
abstract  void mutate()
          Mutate this Gene.
abstract  void randomize()
          Set the value of this Gene to a random value.
abstract  String toString()
          Return the value of this Gene as a String.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Gene

public Gene()
Method Detail

copy

public final Gene copy()
Generate an exact copy of this Gene. The type of the Gene returned will be the same as the type of the Gene on which it was invoked. Note this method is final and relies on the clone() method. Thus, any Gene sub-class wishing to control how it is copied must override the clone method.

Returns:
a copy of this Gene created by invoking its clone method.

clone

public Gene clone()
Create a clone of this Gene. The type of the Gene returned will be the same as the type of the Gene on which it was invoked. The clone is created by invoking clone() in the Object class. If a sub-class contains non-primitive fields that should be cloned and initialized it must override clone(), being sure to invoke this method via super.clone().

Overrides:
clone in class Object
Returns:
a clone of this Gene.

mutate

public abstract void mutate()
Mutate this Gene.


randomize

public abstract void randomize()
Set the value of this Gene to a random value.


toString

public abstract String toString()
Return the value of this Gene as a String.

Overrides:
toString in class Object
Returns:
a String representation of this Gene.

equals

public abstract boolean equals(Object obj)
Determine if this Gene is equal to the Gene obj.

Overrides:
equals in class Object
Returns:
true if this Gene is equal to the Gene obj and false otherwise.

dLife Home Page