I have a problem. I want that the class trefferpunkte ... the variable treffer if a ball is touching a patrone. If I write ball.isTouching(patrone.class) there is an error and I do not understand why.
Here the Code of class trefferpunkte,
ball
and patrone
and here the error

import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class trefferpunkte here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class trefferpunkte extends ball
{
/**
* Act - do whatever the trefferpunkte wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int treffer;
public trefferpunkte(){
setRotation(0);
treffer=Greenfoot.getRandomNumber(80)+20;
}
public void act()
{
ball ball = (ball) getWorld().getObjects(ball.class).get(0);
patrone patrone = (patrone) getWorld().getObjects(patrone.class).get(0);
if(ball!=null){
if(ball.isTouching(patrone.class)){
ball.removeTouching(patrone.class);
treffer--;
}
}
if(treffer==0){
removeTouching(ball.class);
getWorld().removeObject(this);
}
setLocation(xpos, ypos);
Color trans = new Color(0, 0, 0, 0);
setImage(new GreenfootImage(Integer.toString(treffer), 30, Color.BLACK, trans));
// }
}}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class ball here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class ball extends Actor
{
/**
* Act - do whatever the ball wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
int x;
int x2;
public static int i;
public static int xpos;
public static int ypos;
private int trefferpunkte;
public ball(){
this.getImage().scale(60,60);
setRotation(270);
x=15;
i=Greenfoot.getRandomNumber(2);
trefferpunkte=100;
if(i==0){
x2=1;
}
if(i==1){
x2=-1;
}
}
public void act()
{
xpos=getX()+x2;
ypos=getY()+(x/5);
if(isAtEdge()){
x2=x2*-1;
}
setLocation(getX()+x2, getY()+(x/5));
if(getY()<300){
x++;;
}
if(getY()>380){
x=x*-1;
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class kugeln here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class patrone extends kanone
{
/**
* Act - do whatever the kugeln wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public patrone(){
this.getImage().scale(5,10);
}
public void act()
{
setLocation(getX(), getY()-5);
if(isAtEdge()){
getWorld().removeObject(this);
}
}
}
