The isColourInCode() method doesn't need to set a variable to true, it can just return true the first time the if statement is true.

The way to handle your problem is to make a copy of the secret code, find all matching pegs first and remove them from the copy (or set them to a special value denoting matched). Then look for incorrect values by checking against the copy.