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

2014/7/13

sharing variables between classes

thepangolin thepangolin

2014/7/13

#
in java i can do private int derp public String getDerp(){ return derp; } under class one and then do myTwo.getCalories under class two, can i do something similar in greenfoot?
danpost danpost

2014/7/13

#
thepangolin wrote...
in java i can do private int derp public String getDerp(){ return derp; } under class one and then do myTwo.getCalories under class two, can i do something similar in greenfoot?
Of course. The language for Greenfoot IS Java. However, if 'derp' is to hold an 'int' value, you should have:
public int getDerp()
('int' -- not 'String').
thepangolin thepangolin

2014/7/28

#
ok, thank u
You need to login to post a reply.