Provide your Block class with a getColor() method to return the lock's colour. Then inside a for loop call this method for each block in the list.