The source code of the automatically generated ‘prepare’ method may be freely edited by hand.Students can study the generated code and learn from it. We consciously chose to create source code (rather than, say, serialising the world objects) because it can serve as a good learning instrument.There are a few characteristics worth noting about this mechanism: The effect is that next time, when I recompile my class and the world is re-created, the objects in the world are re-created as well. Let us further assume that I have just created the pigs and the hamburger interactively and placed them into my world. Let us assume I want a scenario where the initial objects at the start of the game are a hamburger and three pigs. You can now insert the objects you initially want in the world interactively, and then save the visible state of the world as the starting state of your program. So we come to the rescue: Saving the World. However, writing these initialiser methods can be tedious. This solves the problems, since objects get recreated automatically. This could be overcome by writing an initialiser method in the world class that creates and inserts all the objects you want to have in the world. (This was not a bug: it is necessary, because the class implementing these objects does not exist anymore.) In previous editions of Greenfoot, there was one annoying aspect: every time you had to recompile your classes, your interactively created objects disappeared. Earlier today I wrote about the new Greenfoot features.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |