Add()不能用Java(Greenfoot)工作

时间:2018-05-14 08:11:32

标签: counter greenfoot

import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and 
MouseInfo)

/**
 * Write a description of class MyWorld here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MyWorld extends World
{
private Counter counter;
public Counter würfelanzahl;
public int Felder;
/**
 * Constructor for objects of class MyWorld.
 * 
 */
public MyWorld()
{    
    // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
    super(900, 900, 1); 
    addObject(new Würfel1(), 400, 500);
    addObject(new Würfel2(), 500, 500);
    addObject(new Auto(), 825, 825);
    addObject(new katze(), 790, 800);
    würfelanzahl=new Counter("Felder: ");
    addObject(würfelanzahl, 465, 550);
    *getwürfelanzahl().add(100);*
    Felder=0;
}
public Counter getwürfelanzahl()
{
    return würfelanzahl;
}
public void addwürfelanzahl(int würfelanzahl)
{
    Felder+=würfelanzahl;
}
}

这里我尝试向Counter添加一个整数。我不明白为什么add()不起作用。我得到错误,它没有找到符号,并询问我的意思是act()。奇怪的是我复制了我编写的其他程序,并且它没有问题。

0 个答案:

没有答案