Hello, in order to follow my teacher orders and to use encapsulation I mustn't have any public variables so I'm trying to declare them as private in one class but I'm in owe to use them in another class.
How would I should i proceed in orther to do this?
Example of what I'm trying to do:
Then in the tank class i want to be able to access the bullets variable like so:
So if I had the variable declared has public static this would work, but since I need to declare them all private (teacher request) I don't know what should I do, if that's even possible in Greenfoot.
Thanks
1 2 3 | public class Tank extends Actor{ private static bullets = 40 ; } |
1 2 3 | public class Tank extends Actor{ Bullet.bullets ... // do something } |