Description
This activity will have you create a new actor subclass using the Greenfoot support class collection. In this activity, you will:
- Create a new class Mover by reusing a Greenfoot Support Class.
- Create a subclass of Mover and show how to use its features.
- Run the scenario.
- Learn some Java constructs and programming concepts along with reviewing the code.
Skills you will learn include:
- Being able to use the Greenfoot support classes and API documentation to create your own new classes and subclasses.
- Learn Java as well as basic programming concepts and constructs.
Basic Steps
- Start up Greenfoot.
- From the Scenario menu, select the scenario called Monsters.
- Next, create a subclass of Actor called Mover. Open the editor and copy and paste this code for the Mover class. You can learn more about Mover and other Greenfoot Support Classes in the Greenfoot Programmer's Manual.
- Create a subclass of Mover. We’ll call it MovingMonster. Choose a monster image from the library, create your own image or use this image.
- Edit MovingMonster, adding a method called act(). The code for act() can be found here.
- Compile, add MovingMonster objects and run the scenario. This time when you click run, randomly hold down the left arrow OR the right arrow keys. See how the behavior changes.
- Learn more about the Greenfoot Mover class and additional Java programming tips at the Greenfoot Support Classes - Digging Deeper page.
- Please read the following instructions for preparing your work prior to submission to this activity.
- Select Scenario -> Export. Choose Webpage (from Publish, Webpage, Application) and select a location to save the scenario as an applet (a jar file and a .html file).
- Submit the exported jar file for this activity.



