xiqiaowen 2015-11-10 02:31 采纳率: 0%
浏览 5988

JAVA代码编译出错:找不到符号,求解答

源代码:
package com.tarena.shoot;
import java.util.Random;
//Airplane----敌机既是飞行物,
public class Airplane extends FlyingObject implements Enemy{
private int speed = 2;//敌机走步的步数
public Airplane(){
image = ShootGame.airplane;
width = image.getWidth();
height = image.getHeight();
Random rand = new Random();
x = rand.nextInt(ShootGame.WIDTH - this.width);
y = -this.height; //y:负的敌机的高

}

//重写 getScore();
public int getScore(){
    return 5;
}

public void step(){
    y += speed;
}
public boolean outOfBounds(){
    return this.y > ShootGame.HEIGHT;      //敌机的y坐标大于窗口的高

}

}

出错:
---------- javac ----------
Airplane.java:4: 错误: 找不到符号
public class Airplane extends FlyingObject implements Enemy{
^
符号: 类 FlyingObject
Airplane.java:4: 错误: 找不到符号
public class Airplane extends FlyingObject implements Enemy{
^
符号: 类 Enemy
Airplane.java:7: 错误: 找不到符号
image = ShootGame.airplane;
^
符号: 变量 image
位置: 类 Airplane
Airplane.java:7: 错误: 找不到符号
image = ShootGame.airplane;
^
符号: 变量 ShootGame
位置: 类 Airplane
Airplane.java:8: 错误: 找不到符号
width = image.getWidth();
^
符号: 变量 width
位置: 类 Airplane
Airplane.java:8: 错误: 找不到符号
width = image.getWidth();
^
符号: 变量 image
位置: 类 Airplane
Airplane.java:9: 错误: 找不到符号
height = image.getHeight();
^
符号: 变量 height
位置: 类 Airplane
Airplane.java:9: 错误: 找不到符号
height = image.getHeight();
^
符号: 变量 image
位置: 类 Airplane
Airplane.java:11: 错误: 找不到符号
x = rand.nextInt(ShootGame.WIDTH - this.width);
^
符号: 变量 x
位置: 类 Airplane
Airplane.java:11: 错误: 找不到符号
x = rand.nextInt(ShootGame.WIDTH - this.width);
^
符号: 变量 ShootGame
位置: 类 Airplane
Airplane.java:11: 错误: 找不到符号
x = rand.nextInt(ShootGame.WIDTH - this.width);
^
符号: 变量 width
Airplane.java:12: 错误: 找不到符号
y = -this.height; //y:负的敌机的高
^
符号: 变量 y
位置: 类 Airplane
Airplane.java:12: 错误: 找不到符号
y = -this.height; //y:负的敌机的高
^
符号: 变量 height
Airplane.java:23: 错误: 找不到符号
y += speed;
^
符号: 变量 y
位置: 类 Airplane
Airplane.java:26: 错误: 找不到符号
return this.y > ShootGame.HEIGHT; //敌机的y坐标大于窗口的高
^
符号: 变量 y
Airplane.java:26: 错误: 找不到符号
return this.y > ShootGame.HEIGHT; //敌机的y坐标大于窗口的高
^
符号: 变量 ShootGame
位置: 类 Airplane
16 个错误

  • 写回答

2条回答 默认 最新

  • 独木成舟 2015-11-10 02:52
    关注

    接口和父类可能不在同一包下,需要引入包,也可能你定义的父类和接口权限不够。

    评论

报告相同问题?

悬赏问题

  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗