// 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:   AbstractCrossover.java

package drm.genetics;

import java.util.Random;

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

public abstract class AbstractCrossover
	implements Crossover
{

	protected Random random;
	protected int type;

	public AbstractCrossover()
	{
		random = new Random();
		type = 1;
	}

	public AbstractCrossover(int type)
	{
		random = new Random();
		this.type = 1;
		setType(type);
	}

	public void setType(int type)
	{
		this.type = type;
	}

	public int getType()
	{
		return type;
	}

	public Individual cross(Individual individ1, Individual individ2)
	{
		Individual ind1 = null;
		Individual ind2 = null;
		try
		{
			ind1 = (Individual)individ1.getClass().newInstance();
			ind2 = (Individual)individ2.getClass().newInstance();
			ind1.accessGenome(individ1.getGenome());
			ind2.accessGenome(individ2.getGenome());
			crossSame(ind1, ind2);
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
		return ind1;
	}
}
