![]() ![]() The source code is written in Java and contains all the details about a class and its objects. For this we need to open the source code in the editor: Right-click on the class MyKara then choose Open editor (or just use a double-click). Now let’s see where the behavior of this method is programmed. What methods can be found when you right-click on MyKara and then inherited from Kara? Can you use them?.What happens if you press the Act button in the Greenfoot controls?.Place a MyKara object into your world.These operations are called methods in Java. The object menu of Kara shows us what Kara can do. To interact with objects in the world, we click with the right mouse button to bring up the object menu. Tip: To create multiple objects of the same class, press the Shift-key before you click. Then move the object anywhere in the world and click where you wish to place it.Ĭreate an object of (the gray!) Kara. In Greenfoot, we create new objects as follows: Right click on the class of Kara and choose the menu item new Kara(). The produced ladybugs are called objects (or instances). Kara is the class for the general concept of a ladybug - so to speak, it is like a blue-print from which we can create individual ladybugs. For object-oriented programming, the concepts of classes and objects are of fundamental importance.Ĭonsider the class of Kara. Java is a so-called object-oriented language. We will come to that later.įor our projects we use the Java programming language. The Greenfoot Controls: The buttons Act, Run, and Reset and the speed slider at the bottom serve the controlling of the program.First, we will mainly need the beetle Kara. The class Diagram: The area to the right contains the classes that are available to us.In the Kara scenario it is a green meadow with gridlines. This is the area when the program runs, we can see what happens. The world: The largest area is called world.The Greenfoot window consists of three main areas and a few additional buttons. It now appears in the main Greenfoot window similar to the following: ![]() ![]() Open the scenario Kara 101 First Steps from the folder scenarios-chapter-1. (If you open Greenfoot for the first time, a dialog box asks what you’d like to do. In this chapter we will take our first steps in programming. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |