The opposing type is “private”, which means that that piece of code is only accessible within that object.īecause this line is part of what defines a Crab, which is an actor that is to be placed in the World, it would not make sense to make it a private type – what good is an actor that can’t be on stage?. This tells us that this object/code is globally accessible, meaning that other objects can reffer to this object/code. This sentence starts with the word “public”. Examples of such can be found from lines 3~5.Īfter all the comments a archaic sentence awaits Multi-line comments are colored blue and are generally used to give descriptions of the entire object and its useage. Multi-line comments are written after /* and goes on until */ is met. They are generally used to describe methods or specific codes briefly Single line comments are written after // and is colored grey. There are 2 types of comments in Greenfoot: Single line comments and Multi-line comments. the grey part written after // is an example of a comment. Such information can be easily known from the comments. These classes contain the most core methods you will use while you program in Greenfoot. This package includes the classes World, Actor, GreenfootImage and Greenfoot. “greenfoot” written in black signifies the name of the package you will import. * Methods are like skills your “Object” can use. Import is a function that calls for a “package” of methods. Import greenfoot.* // (World, Actor, GreenfootImage, and Greenfoot) Let’s try to identify some items on here brieflyĪt the top of the code, we can see in red, black, and grey When you do that, you will find a new window titled “Crab” has popped up. This time click on “Open editor”, which is the second line from top. You used it last time to place the crab in the world Remember this? This is what you get when you right click on Crab. Now then, let’s try to make the crab move! If somehting happened, you’ve messed around with the codes. If nothing happened, don’t worry, that’s completely normal. Right click it and click “new Crab()” then place the crab in the world. Once you do this, you will see that you have a world full of sand, like a beach where crabs normally live. You can do this by clicking on the “Compile” buttom on the bottom right corner. You can also identify that the only actor in this world is “Crab”Īpart from that, the screen is all grey and you don’t seem to be able to do anything here…hmm… Let’s try compiling it. Once you open up the program, this will be the screen that greets youįrom previous posts, you can identify that the World in this program is titlted “CrabWorld”, which allows you to predict that crabs will exist in this world. If then, search for the Greenfoot software on your computer and select it. The system might ask you to specify which program to use. Unzip the zipped file and double click on the file titled “eenfoot” Go to the right top of the page and you will find a tab labled “Download”. Lets start by downloading the “Little Crab” file from the link below (This file is an excerpt from the Greenfoot textbook’s chapter 2)
0 Comments
Leave a Reply. |