danpost wrote...
Create a new sub-class of World called 'Level'. The code below is a general outline of what it should consist of. Then, make all the worlds that the player and counter will be in extend this 'Level' world. The fields declared in the 'Level' world should not be declared in those sub-classes; only used by them, including adding the objects into those worlds. Use the methods given directly in the sub-worlds. To reference these objects in other classes, use dot notation on the class name 'Level' (example: 'Level.getScoreCounter().add(5);').
import greenfoot.*;
public class Level extends World
{
private static int levelNum;
private static Player player = new Player();
private static Counter scoreCounter = new Counter("Score:");
public Level(int wide, int high, int size)
{
super(wide, high, size);
}
public static Counter getScoreCounter()
{
return scoreCounter;
}
public static Player getPlayer()
{
return player;
}
public static int getLevel()
{
return levelNumber;
}
public static void changeLevel(int difference)
{
levelNumber += difference;
switch (levelNumber)
{
case 0: Greenfoot.setWorld(new World0()); break;
case 1: Greenfoot.setWorld(new World1()); break;
case 2; Greenfoot.setWorld(new World2()); break;
// etc.
}
}

