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
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题