Java: creating a specific class -
i have class constructed that:
public class creature { protected final ai ai; // ...about 10 other objects public creature (creaturetype type, int x, int y) { ai = new ai (); // other code } // ... many methods }
my class ai artificial intelligence of creature. have full access creature object if inside. how achieve that? tricky way inherit it?
making ai inner class of creature give ai access creature's instance variables.
see: http://docs.oracle.com/javase/tutorial/java/javaoo/nested.html
Comments
Post a Comment