// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   AbstractIndividual.java

package drm.genetics;


// Referenced classes of package drm.genetics:
//			Gene, Individual

public abstract class AbstractIndividual
	implements Individual
{

	protected Gene genome[];
	protected double weight;

	public AbstractIndividual()
	{
		genome = new Gene[0];
		weight = (-1.0D / 0.0D);
	}

	public Gene[] accessGenome()
	{
		return genome;
	}

	public void accessGenome(Gene genome[])
	{
		this.genome = genome;
	}

	public Gene[] getGenome()
	{
		Gene out[] = new Gene[genome.length];
		System.arraycopy(genome, 0, out, 0, genome.length);
		return out;
	}

	public void setGenome(Gene genome[])
	{
		this.genome = new Gene[genome.length];
		System.arraycopy(genome, 0, this.genome, 0, genome.length);
	}

	public int compareTo(Object individual)
	{
		double ths = getWeight();
		double otr = ((Individual)individual).getWeight();
		int out = 1;
		if(ths > otr)
			out = -1;
		if(individual.equals(this))
			out = 0;
		return out;
	}

	public double getWeight()
	{
		return weight;
	}

	public void setWeight(double weight)
	{
		this.weight = weight;
	}

	public Individual copy()
	{
		AbstractIndividual ind = null;
		try
		{
			ind = (AbstractIndividual)getClass().newInstance();
			ind.accessGenome(getGenome());
			ind.weight = weight;
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
		return ind;
	}
}
