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

2018/11/13

Question about an if statement

Toodumbtocode Toodumbtocode

2018/11/13

#
How do you make an if statement to detect if your actor has eaten 3 things? I'll give an example in psuedocode if dog eats 3 treats { the dog dances } how do i translate that????
danpost danpost

2018/11/13

#
Toodumbtocode wrote...
How do you make an if statement to detect if your actor has eaten 3 things? I'll give an example in psuedocode << Psuedocode Omitted >> how do i translate that????
First, you need a field to count the number of treats eaten, call it treatsEaten, and a method to make the dog dance, call it dance. Then, the translation would be:
if (treatsEaten == 3) dance();
You need to login to post a reply.