BlueJ中出现错误代码'{'

时间:2017-10-23 18:30:10

标签: bluej

我正在尝试用高中编码班来帮助我的儿子,我们无法解决这个问题。我已经能够解决其他编码问题,但找不到任何关于修复这个特定问题的答案(即使是通过网络)。

以下是编码公式:

/**
* Write a description of class Tia here.
*
* @author (your name)
* @version (a version number or a date)
*/

import objectdraw.*;
import java.awt.*;

public class AlexisSmile extends FrameWindowController (Error message: '{' Expected)

    FilledOval head = new FilledOval (100,100,200, 200, canvas);
    FilledOval eyeR = new FilledOval (130, 130, 70, 60, canvas);
    FilledOval eyeL = new FilledOval (200, 130, 70, 60, canvas);
    FilledOval pupilR = new FilledOval (150, 130, 50, 40, canvas);
    FilledOval pupilL = new FilledOval (220, 130, 50, 40, canvas);
    FilledArc mouth = new FilledArc (150, 100, 100, 200, 0, -180, canvas);
    FilledArc insideMouth = new FilledArc (160, 115, 80, 0, -180, canvas);

    /**
    * This changes the color of the different shapes for the smiley face.
    */
    public void begin()
    {
        head.setColor(Color.yellow);
        pupilR.setColor(Color.red);
        pupilL.setColor(Color.red);
        insideMouth.setColor(Color.pink);
    } 


}

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

我对bluej并不熟悉,但似乎是在试图告诉你忘记了{名字之后的class开头。

:此:

/**
* Write a description of class Tia here.
*
* @author (your name)
* @version (a version number or a date)
*/

import objectdraw.*;
import java.awt.*;

public class AlexisSmile extends FrameWindowController {

    FilledOval head = new FilledOval (100,100,200, 200, canvas);
    FilledOval eyeR = new FilledOval (130, 130, 70, 60, canvas);
    FilledOval eyeL = new FilledOval (200, 130, 70, 60, canvas);
    FilledOval pupilR = new FilledOval (150, 130, 50, 40, canvas);
    FilledOval pupilL = new FilledOval (220, 130, 50, 40, canvas);
    FilledArc mouth = new FilledArc (150, 100, 100, 200, 0, -180, canvas);
    FilledArc insideMouth = new FilledArc (160, 115, 80, 0, -180, canvas);

    /**
    * This changes the color of the different shapes for the smiley face.
    */
    public void begin()
    {
        head.setColor(Color.yellow);
        pupilR.setColor(Color.red);
        pupilL.setColor(Color.red);
        insideMouth.setColor(Color.pink);
    } 

}

应解决语法错误。

我还注意到你将canvas传递给方法,但是没有声明它......所以下一个错误可能就是canvas can not be resolved。我可以假设它应该是java.awt.Canvas的一个实例,但你需要声明并实例化它。