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

2013/3/29

Referencing Statements

Gingervitis Gingervitis

2013/3/29

#
Is there a way to reference a boolean from statement from another class. For example, I have a boolean statement in my Lobster class that cannot eat the crab when the statement is false. Is there a way to make it to return true from my crab class?
danpost danpost

2013/3/29

#
Did you try inserting the code I supplied in the other discussion? It has a method that the Lobster class can call that will return a true/false value from the Crab class.
JetLennit JetLennit

2013/3/29

#
1. in the calling of your variable make it like
public static boolean yourboolean
2. in your Lobster put something like this in
public static boolean getBoolean()
    {
       return yourboolean;
    }
3. in you crab one put something like
public static boolean yourotherboolean = (getBoolean) 
i sincerely hope this works
Gingervitis Gingervitis

2013/3/29

#
I did try your code and the lobster still eats me when I have the power-up and I would like to know how to make this work for other power-ups . . . I might have missed something.... should I re-post the game?
JetLennit JetLennit

2013/3/29

#
okay....... so try from the crab doing Lobster.YourBoolean when you want to call you variable
Gingervitis Gingervitis

2013/3/29

#
Oh I'm sorry JetLennit ... that response was for Danpost's reply...
JetLennit JetLennit

2013/3/29

#
okay...
You need to login to post a reply.