I am sorry I feel dumb now but I really dont understand
import greenfoot.*;
import java.awt.Color;
/**
* A waterspray can be sprayed by the gardener. It helps to give plants water.
*
*/
public class Snowman extends Actor
{
// Field with an objectreference to the gardener that sprayed this water
Gardener gardener;
int setSnowman;
/**
* Set the objectreference to the gardener
* @param g The objectreference to the gardener
*/
public void act () {
move(0);
if (isTouching (Plant.class)){
Plant plant = (Plant)getOneIntersectingObject (Plant.class);
plant.addWater(1);
gardener.addPoints(1);
World world = getWorld();
world.removeObject (this);
}
move(0);
if (isTouching (Plant.class)){
Plant plant = (Plant)getOneIntersectingObject (Plant.class);
plant.addWater(1);
gardener.addPoints(1);
World world = getWorld();
world.removeObject (this);
}
if (Greenfoot.isKeyDown("space")) {
World world = getWorld();
WaterSpray waterSpray = new WaterSpray(this);
world.addObject(waterSpray, getX(), getY());
}
}
}
public static Gardener gardener;
public Gardener()
{
WaterSpray.gardener = this;
}import greenfoot.*;
import java.awt.Color;
/**
* A waterspray can be sprayed by the gardener. It helps to give plants water.
*
*/
public class WaterSpray extends Actor
{
// Field with an objectreference to the gardener that sprayed this water
public static Gardener gardener;
/**
* Set the objectreference to the gardener
* @param g The objectreference to the gardener
*/
public void Gardener(){
{
gardener = g;
}
}public void act () {
move(3);
if (isTouching (Plant.class)){
Plant plant = (Plant)getOneIntersectingObject (Plant.class);
plant.addWater(1);
gardener.addPoints(1);
World world = getWorld();
world.removeObject (this);
}
}
}if (getObjects(Snowman.class).isEmpty()) addObject(new Snowman());
import greenfoot.*;
/**
* Within the GreeneryWorld there walks a gardener to water his plants.
*
*/
public class GreeneryWorld extends World
{
/**
* Constructor for objects of class GreeneryWorld.
*
*/
public void act(){
if (getObjects(Snowman.class).isEmpty())
addObject(new Snowman());
}
public GreeneryWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
// Objects can move outside the edges of the world
super(600, 400, 1, false);
// Create a new gardener and put in the world
addObject (new Gardener(), 300,200);
// Create a new timer and put it in the upper left corner
addObject (new Timer(),25,15);
}
}
blic GreeneryWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
// Objects can move outside the edges of the world
super(600, 400, 1, false);
// Create a new gardener and put in the world
addObject (new Gardener(), 300,200);
// Create a new timer and put it in the upper left corner
addObject (new Timer(),25,15);}
{
if (getObjects(Snowman.class).isEmpty())
addObject(new Snowman());
}
}