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

2019/12/10

How do I create a method to do the following, and does the order matter

Vishnu19 Vishnu19

2019/12/10

#
Hello all, I would like to know how to write a statement that would generate integer values between -40 and 40 inclusive in an actor class. Also, does the order that statements occur in a method matter? Would like some examples of why or why not. Any help would be much appreciated!
danpost danpost

2019/12/10

#
Vishnu19 wrote...
I would like to know how to write a statement that would generate integer values between -40 and 40 inclusive in an actor class.
You can generate a random value in that range with:
int rand = 40-Greenfoot.getRandomNumber(81);
Also, does the order that statements occur in a method matter?
Sometimes, yes; sometimes, no. It really depends on what the statements do. You would have to ask about the specific statements themselves.
Vishnu19 Vishnu19

2019/12/10

#
Very helpful, thanks!
You need to login to post a reply.