Ругается на метод move(). Не могу понять что ему не нравится...
package com.javarush.task.task25.task2515;
import java.util.Random;
public class Ufo extends BaseObject {
//картинка корабля для отрисовки
private static int[][] matrix = {
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{1, 0, 1, 0, 1},
{1, 1, 1, 1, 1},
};
public Ufo(double x, double y) {
super(x, y, 3);
}
@Override
public void draw(Canvas canvas) {
canvas.drawMatrix(x - radius + 1, y - radius + 1, matrix, 'U');
}
@Override
public void move() {
double dx = Math.random() * 2 - 1; //-1..1
double dy = Math.random() * 2 - 1; //-1..1
x = x + dx;
y = y + dy;
if (y <= Space.game.getHeight()/2)
y=y-dy;
checkBorders(radius, Space.game.getWidth() - radius + 1, radius, Space.game.getHeight() + 1);
if (new Random().nextInt(10) == 1)
fire();
}
public void fire() {
Space.game.getBombs().add(new Bomb(x, y-3));
}
}
package com.javarush.task.task25.task2515;
import java.util.ArrayList;
public class Space {
private int width;
private int height;
private SpaceShip ship;
private ArrayList<Ufo> ufos = new ArrayList<>();
private ArrayList<Rocket> rockets = new ArrayList<>();
private ArrayList<Bomb> bombs = new ArrayList<>();
public static Space game;
public static void main(String[] args) {
}
public Space(int width, int height) {
this.width = width;
this.height = height;
}
public void run() {
}
public void draw() {}
public void sleep(int ms) {}
public void setShip(SpaceShip ship) {
this.ship = ship;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public SpaceShip getShip() {
return ship;
}
public ArrayList<Ufo> getUfos() {
return ufos;
}
public ArrayList<Rocket> getRockets() {
return rockets;
}
public ArrayList<Bomb> getBombs() {
return bombs;
}
}