 
/********************************************************************* 
 * Candidates can be created from either Voters or Reps.  If created 
 * from a Voter, the Voter's place in the District Vector is kept as 
 * part of it's internal variables.  If created from a Rep, then the  
 * incumbent tag is changed to true and the age of the candidate is 
 * set equal to the age of the Rep.  Candidates will adapt in future 
 * versions of this program. 
 ********************************************************************/ 
public class Candidate extends Individual { 
    public boolean incumbent = false; 
    public int VoterID = -1; 
    public int age = Math.abs(Utilities.rand.nextInt() % 30); 
    public int votesReceived = 0; 
    public double majority;
 
    // Constructor when incoming individual is a Voter 
    public Candidate(Voter tempCand, int ID) { 
	ideology = tempCand.ideology; 
	strengths = tempCand.strengths; 
	votingRecord = tempCand.votingRecord; 
	partyTag = tempCand.partyTag; 
	name = "Candidate from " + tempCand.name; 
	VoterID = ID; 
	parent = tempCand.parent; 
    } 
 
    // Constructor when incoming individual is a Rep 
    public Candidate(Rep tempCand) { 
	ideology = tempCand.ideology; 
	strengths = tempCand.strengths; 
	votingRecord = tempCand.votingRecord; 
	partyTag = tempCand.partyTag; 
	name = tempCand.name; 
	VoterID = tempCand.VoterID; 
	incumbent = true;
	majority = tempCand.majority;
	age = tempCand.age; 
	parent = tempCand.parent; 
    } 
 
    // Steal positions from another candidate [Gone Fishin']
    public void Crossover(int[] newIdeo) { 
	
	for (int i=0; i<ideology.length; i++) { 
	    double sacrifice = 1 - ((double)votesReceived /  
				    (double)parent.CurrentRep.votesReceived); 
	    if (Utilities.rand.nextDouble() < sacrifice) 
		ideology[i] = newIdeo[i]; 
	} 
    } 
} 
 

