This site requires JavaScript, please enable it in your browser!
Greenfoot back
BubbaB
BubbaB wrote ...

2013/4/2

Pass in a class as a parameter?

BubbaB BubbaB

2013/4/2

#
So I'm creating a method that just simply creates an object given the class, object name, and the x/y position. This isn't a greenfoot specific question, but I'm wondering how I can pass in a class as a parameter. Thanks! Here's the method below. (Doesn't work). public void createObject(Class c, String objectName, int x, int y) { c objectName = new c(); getWorld().addObject(objectName, x, y); }
danpost danpost

2013/4/2

#
I would like to see the block of code that calls this method (the one with 'createObject(c, x, y);').
You need to login to post a reply.