

Integers are numbers that don’t have a decimal point in it (whole numbers) like 3, -2, 56, and 342324432.

If you have any word other than Void tells you that the method will give back some information and what kind of information it will give.įor example, void setDirection(int direction) has int in () because it needs to have an integer. That means that any method that has a Void return type do not give any information, they just do their action and then stop. The word Void means “nothing” in this context. This tells us what the method will return to us when we invoke it. The method also has some information about what kind of data goes in to the method call and what data comes out of it. Just using those two methods, void move () and void setDirection(int direction) set up four of your Wombats to look like this: What happens when you choose different numbers (0~3)? Lastly try void turnLeft(). What does the Wombat do? Now try void setDirection(int direction). You invoke a method by choosing it from the menu. These operations are called methods in Java. The object menu lists all the things that the object can do. Now that we have made a bunch of objects we can make them do something by right-clicking them.

Move your Wombat picture in to the world by clicking anywhere in the world.ġ.1 TRY THIS! Make a bunch of Wombats and leaves and bring them in to the world.ĭoing stuff with Objects ( invoking a method)

Right click on the Wombat class and then the class menu will pop up.Ĭhoose the option at the top of that menu, new Wombat(), and it will make new Wombat objects. When we have a class in Greenfoot, we can create objects from it.You can call an object an instance if you want, in programming they just mean the same thing. Think of it this way, if you had a class called transportation it would include a lot of stuff like trains, planes, boats, roller skates, skateboards, bicycles, cars, trucks…… But if you had a class called skateboards it would have long boards and short skateboards and mini-skateboards, but it would not have any monster trucks in it. For example, class Wombats stands for all Wombats. A class means something that stands for all of the things that belong to it. Since Java is an object-orientated language, it uses objects and classes. They are World, WombatWorld, Actor, Leaf, and Wombat. The three parts are: the World: where the programs will run, and you can see stuff happen, the class diagram: this is where the world and actor classes are, the execution controls: Act, Run, Reset and the speed slider. To see this, start up Greenfoot and click on Scenario in the top left, then choose open and navigate to the leaves-and wombats scenario. Scenarios are programs that do something. The Greenfoot interface is what we see when we create a scenario or load a scenario in to Greenfoot. Greenfoot: an interactive Java environment. Topics: What we are going to talk about: Greenfoot, the Greenfoot interface, doing stuff with objects (interacting), invoking methods, running a scenarioĬoncepts: (ideas you should know at the end of the lesson) object, class, method call, parameter, return value Answer questions in point form, screencap results and code. Make a word doc, define in your own words everything in bold.
