How can the code be compiled and executed for testing to see the problem?

To do the same thing to multiple objects, have a method that does the thing and pass it each object.