public ResultOfCodeComparison compareWith(Code attemptToGuessTheCode)
	{
		boolean[] pegsToProcessInCurrentCode = new boolean[NUMBER_OF_PEGS_IN_THE_CODE];
		boolean[] pegsToProcessInAttempToGuessTheCode = new boolean[NUMBER_OF_PEGS_IN_THE_CODE];
		
		for (int pegNumber=0; pegNumber<NUMBER_OF_PEGS_IN_THE_CODE; pegNumber++)
		{
			pegsToProcessInCurrentCode[pegNumber] = true;
			pegsToProcessInAttempToGuessTheCode[pegNumber] = true;
		}
		
		int numberOfWellPlacedPegs = 0;
		int numberOfMisplacedPegs = 0;
		
		// search for well placed pegs
		for (int pegNumber=0; pegNumber<NUMBER_OF_PEGS_IN_THE_CODE; pegNumber++)
		{
			if (this.pegs[pegNumber].getColor() == attemptToGuessTheCode.pegs[pegNumber].getColor())
			{
				numberOfWellPlacedPegs++;
				pegsToProcessInCurrentCode[pegNumber] = false;
				pegsToProcessInAttempToGuessTheCode[pegNumber] = false;
			}
		}
		
		// search for misplaced pegs
		for (int pegNumberInCurrentCode=0; pegNumberInCurrentCode<NUMBER_OF_PEGS_IN_THE_CODE; pegNumberInCurrentCode++)
		{
			if (!pegsToProcessInCurrentCode[pegNumberInCurrentCode]) continue;
			
			for (int pegNumberInAttemptToGuessCode=0; pegNumberInAttemptToGuessCode<NUMBER_OF_PEGS_IN_THE_CODE; pegNumberInAttemptToGuessCode++)
			{
				if (!pegsToProcessInAttempToGuessTheCode[pegNumberInAttemptToGuessCode]) continue;
				if (this.pegs[pegNumberInCurrentCode].getColor() == attemptToGuessTheCode.pegs[pegNumberInAttemptToGuessCode].getColor())
				{
					numberOfMisplacedPegs++;
					pegsToProcessInCurrentCode[pegNumberInCurrentCode] = false;
					pegsToProcessInAttempToGuessTheCode[pegNumberInAttemptToGuessCode] = false;
					break;
				}
			}
		}
				
		return new ResultOfCodeComparison(numberOfWellPlacedPegs, numberOfMisplacedPegs);
	}