我真的经常搜索这个错误信息的答案,但到目前为止我找不到任何答案。
public interface TileGenerator {
int NUMBER_OF_MOVABLE_TILES = 34;
int NUMBER_OF_LAST_MAGIC_ITEM = 25;
int NUMBER_OF_CONTIGUOUS_MAGIC_ITEMS = 20;
ArrayList<Tile> createTiles();
ArrayList<MagicItem> createMagicItems();
}
和我的子类:
public class RandomTileGenerator implements TileGenerator {
private static final int FIVE = 5;
private static final int THIRTEEN = 13;
private static final int SIXTEEN = 16;
private static final int TWENTYONE = 21;
private static final int TWENTYFIVE = 25;
private static final int TWENTY = 20;
private ArrayList<Tile> list2 = new ArrayList<Tile>(NUMBER_OF_MOVABLE_TILES);
@Override
public ArrayList<Tile> createTiles() {
for (int x = 0; x < FIVE; x++) {
list2.add(new Tri());
}
for (int x = 0; x < THIRTEEN; x++) {
list2.add(new Straight());
}
for (int x = 0; x < SIXTEEN; x++) {
list2.add(new Nook());
}
Collections.shuffle(list2);
return list2;
}
@Override
public ArrayList<MagicItem> createMagicItems() {
int i = 1;
ArrayList<MagicItem> magicItemFound = new ArrayList<MagicItem>();
for (int x = 0; x < TWENTYONE; x++) {
magicItemFound.add(new MagicItem(i));
i++;
}
magicItemFound.set(TWENTY, new MagicItem(TWENTYFIVE));
Collections.shuffle(magicItemFound);
return magicItemFound;
}
}
但我总是收到错误消息:
Labyrinth3Test.java:477: error: method does not override or implement a method from a supertype
@Override
我不知道如何以正确的方式覆盖它,因为我的覆盖注释似乎完全没用。
我希望你能帮助我。