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

2023/3/15

Call getIntersectingObjects() from a subclass of World

MRCampbell MRCampbell

2023/3/15

#
getIntersectingObjects() is protected, so I can not call it from a subclass of World. I was reading the article below... https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html and would love some more context and to know if there is anyway around it.
danpost danpost

2023/3/15

#
MRCampbell wrote...
getIntersectingObjects() is protected, so I can not call it from a subclass of World. I was reading the article below... << Link Omitted >> and would love some more context and to know if there is anyway around it.
I do not know what more can be said about accessibility. However, to get "around it", you could add a new method in the class of the actor to call the method and return its results:
public <A> List<A> getIntersectors(Class<A> cls)
{
    return getIntersectingObjects(cls);
}
Then call this method from the world subclass.
You need to login to post a reply.