/*
 *2013-09-17
 *Conditionals and Loops - You Do Its: pg 283
 *Bradley Forney
 *CIS 127
 *Professor: Craig Sharp
 * 
 *You do its pg. 274, pg. 283, pg. 310, pg. 315, & pg. 320
 *
 */
 
public class DogTriathlonParticipant2
{
	private final int 	NUM_EVENTS;
	private static int 	totalCumulativeScore=0;
	private 			String name;
	private int 		obedienceScore;
	private int 		conformationScore;
	private int 		agilityScore;
	private int 		total;
	private double 		avg;
	private boolean 	scoresAgree;
	
	public DogTriathlonParticipant2(String name, int numEvents, int score1, int score2, int score3)
	{
		this.name			=name;
		NUM_EVENTS			=numEvents;
		
		int totalNot0=0;
		if(score1!=0)
		{
			totalNot0++;
		}
		if(score2!=0)
		{
			totalNot0++;
		}
		if(score3!=0)
		{
			totalNot0++;
		}
		
		
		if (numEvents==totalNot0)
		{
			scoresAgree=true;
		}
		else
		{
			scoresAgree=false;
		}
		
		
		if(scoresAgree)
		{			
			obedienceScore		=score1;
			conformationScore	=score2;
			agilityScore		=score3;
		}
		else
		{
			obedienceScore 		=0;
			conformationScore	=0;
			agilityScore		=0;
		}
		
		
		total				=obedienceScore+conformationScore+agilityScore;
		
		if (NUM_EVENTS==0)
		{
			avg=0;
		}
		else
		{
			avg				=(double)total/NUM_EVENTS;
		}
		
		totalCumulativeScore=totalCumulativeScore+total;
	}
	
	public void display()
	{
		if(!scoresAgree)
		{
			System.out.println("\n---Notice! Number of events for "+name+"does not agree with scores reported.");
		}
		System.out.println("\n"+name+" participated in "+NUM_EVENTS+
			" events and has as average score of "+avg);
		System.out.println("-"+name+" has a total score of "
			+total+" bringing the total cumulative score to "
			+totalCumulativeScore);
	}
}
        