Skip to content

JoC #5: If statements

    The sooner you fall behind, the more time you’ll have to catch up.
        — (unknown)

Continuing straight on from the last episode, we now make the turtle turn at the edge of the world.

Download video

Concepts discussed: method return value, boolean, if statement

Nothing to download – we continue with the scenario from last time.


Report post

Posted in Greenfoot, Joy Of Code.

Tagged with , , .

12 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Chris Jobling says

    I like the color coding feature in Greenfoot … it seems to be a very affective way of encouraging the proper nesting of blocks and is also quite affective at pointing out mismatched braces.

    Report comment

  2. Viv Campbell says

    This episode carefully explained why it was good to turn in small steps but not why it was possible for the turtle to apparently ignore the move (when it was at the edge of the world) and to carry out the turn. Perhaps a mention of this iin this episode would be helpful – even if it is already covered somewhere else.

    Report comment

  3. mik says

    Yes, you’re right, sorry.
    The story is this: Actors cam, by default, not leave the world. If they are at the edge and attempt to move, the move will just hav no effect. (They are just pushing against a wall.)

    So the turtle actually tries to move at every step, but as long as it is facing the edge this has no effect. Once it has turned around sufficiently, the move works again.

    Report comment

  4. Doug says

    Mik, thanks for these video’s i just started going through them and they are GREAT.


    Report comment

  5. Alex Oragz says

    I have always tried to learn programming and your site is by far the best tutorial i have seen.

    Many thanks!

    Report comment

  6. Aditya Gupta says

    I went to the Animal class documentation, but it only shows 1 method, not three. I only showed the void act() method.

    Report comment

  7. Tim says

    This post title says JOC #5, but the video is JOC #4…am I missing something?

    Report comment

  8. Tim says

    Whoops. Now it’s correct. I must’ve been confused

    Report comment

  9. jared says

    For me, it says that my coding doesn’t recognize if (atWorldEdge()) ..

    Report comment

  10. Anonymous says

    Mine also says that my coding doesnt recognize the (atWorldEdge()) and i have exactly what is on your screen…

    Report comment

Continuing the Discussion

  1. Joy Of Code #5 – If Statements - Compu2Learn linked to this post on January 29, 2012

    [...] lesson #5 from Mik we are going to learn about IF [...]

    Report comment

  2. El júbilo de programar – Videotutoriales | CyberHades linked to this post on April 27, 2012

    [...] JoC #5: If statements [...]

    Report comment

Protected by Akismet. Blog with WordPress.
The views expressed in this blog are not necessarily those of the University of Kent. Conditions of Use and Guidelines