JoC #3: Classes and objects

    If a man writes a book, let him set down only what he knows.
    I have guesses enough of my own.

          — Goethe

Alright, now it finally starts getting interesting! After the previous talk about installation, now we’re getting started actually doing stuff.

Watch this episode to get the first feel for working with Greenfoot, and see what classes and objects are all about.

Download video

Concepts discussed: class, object, method, instance, return value, return type, void, int, boolean

And, as I said in the video: Follow @JoyOfCode on Twitter to get updates when new episodes are posted.

Scenario download for this episode: hedgehogs.zip      (save and unzip before opening)

16 thoughts on “JoC #3: Classes and objects

  1. Michael

    There may be an issue with Greenfoot if you have BlueJ installed on a Mac. I downloaded and installed installed the latest Greenfoot (2.1.2) and downloaded the Hedgehogs scenario. When I opened it I got a message saying that there was a version mismatch “The scenario being opened has been written using an older version of Greenfoot (before Greenfoot version 0.5) This will most likely result in some errors that will have to be fixed manually. The scenario didn’t open and hedgehogs was a blank scenario with just the World and Actor classes visible.

    Out of interest, I checked the version from the Greenfoot menu and to my suprise it returned the BlueJ splash screen (for 3.0.5 I think). I deleted the BlueJ app, and Greenfoot started fine, opened the Hedgehogs scenario and correctly reported itself as Greenfoot 2.1.2.

    Does this mean that there is a possible conflict with BlueJ or just the older version of BlueJ that I had installed?

    Machine is Mac OS X 10.7 (Lion) and JDK 1.6.

  2. Hi Chris,

    The fact that BlueJ was installed on your system probably has nothing to do with it, and the fact that is fixed itself when you deleted BlueJ is most likely coincidence.

    I am not sure where the version conflict message comes from. It shouldn’t have done that – there’s possibly a bug in there somewhere.

    However, the BlueJ About screen is normal. Greenfoot shares a large amount of code with BlueJ, and the BlueJ code is somewhere deep inside it’s internals. When you run Greenfoot on the Mac, you can see two processes (two icons in the dock). When the Greenfoot window is selected (the main Greenfoot process) you will see a correct Greenfoot About dialogue. When the background process is selected from the dock (or Greenfoot fails to start correctly) the About dialogue you see comes from the innards of the code — and shows the BlueJ one. Unexpected, I know, but not commonly seen.

    My guess is that your problem would have disappeared on the second attempt to start anyway, independent of BlueJ. (I am running BlueJ and Greenfoot quite happily on my system. In fact, I probably have about a dozen different versions installed…)

    However, I don’t know yet what caused this problem in the first place.

  3. OK, but as both icons are green feet … it’s not that obvious which is a background and which is a foreground process! As you say, surprising. I’m not sure that it’s a coincidence though, because I tried opening the Hedgehog scenario a couple of times: both from within the original process and again after quitting Greenfoot, and reopening the scenario file. I did this from the unzipped file, rather than the expanded project folder, if this is a clue.

    I then deleted the BlueJ app (by dragging the Bluej.app file from the Applications folder to the Trash) and Greenfoot worked fine.

    CJ

  4. class, object, method, instance, return value, return type, void, int, boolean all these stuff just in one episode.
    Congrats!! You did it perfectly well. This greenfoot environment is fantastic 🙂
    Great job!!!!

  5. I like how conceptual understanding of the material (terms like class, object, etc.) evolves over time and is prompted by the student desire to do and better coding. Greenfoot addresses the motivational aspects very effectively.

    The help I need as a teacher is to have the definitions of the salient concepts of each module revisited (if needed) in subsequent modules to reflect the student deeper learning of the concepts. This is to assure the skeptics that having fun coding is conducive of conceptualizing what students end up knowing how to do.

    Another big help is to build along the way a bank of smart multiple choice questions that address the most prevalent misconceptions students have. A question would address, in principle, a “type” of misconception, but could be easily a set of similar variants based on the specific context.

  6. Hello Mik,
    I’ve just downloaded and installed GreenFoot Ver 2.1.2 successfully, however I was not able to locate the Hedgehogs Scenario. I did search for the scenario a number of times but could not locate the source files for download. Could you direct me to the link. Great course by the way my son is enjoying it a great deal.

  7. The scenario download is here on the page for this blogpost, a few lines below the video. It’s a zip file (hedgehogs.zip). Download it, unzip it, and then you can open it.

  8. Pingback: Joy of Code #3 – Classes and Objects - Compu2Learn

  9. Actually when i saw the lovely pink values pop-up i am so happy, because when i was doing exercises of eric roberts java i frequently needed those current values, so i had to write another program for that. GREEN FOOT ROCKS. so easy to learn. thanks a lot.

  10. Pingback: Servicios Web Gratis » El júbilo de programar – Videotutoriales

  11. Pingback: Adventures in teaching ICT and Computing » Blog Archive » Greenfoot (7) – videos for lazy teachers

  12. Aidan, the link is just above, where it says:

    Scenario download for this episode: hedgehogs.zip (save and unzip before opening)

    Please note the ‘unzip before opening’ part is critical – it seems this zip was created on a Mac, and the Mac zip functionality always includes an extra “hidden” folder which confuses Greenfoot.

Leave a Reply

Your email address will not be published. Required fields are marked *