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

2013/9/4

Can I call method of different class. See the hierarchy.

savanibharat savanibharat

2013/9/4

#
I must use this hierarchy as it is my assignment Class hierarchy Actor | |___Aliens | |___BallPickers | |___RandomBallPicker | |_ PickingMachine I want to call the method of class RandomBallPicker from class Machine. Can I do so?? If yes, how??
anant.gaggar anant.gaggar

2013/9/4

#
U mean from class PickingMachine...no you cant....for that u need to extend ur PickingMachine Class to class RandonBallPicker
davmac davmac

2013/9/4

#
Yes, you can, if the method is public. You need a reference to the RandomBallPicker that you want to call the method on (unless the method is static). There is a tutorial covering this here.
You need to login to post a reply.