method does not override or implement a method from a supertype: How can make override work?

271 views Asked by At

I really searched a lot to find the answer to this error message but somehow nothing I have found so far answered my question.

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();

}

and my subclass:

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;

}

}

But I always get the error message:

Labyrinth3Test.java:477: error: method does not override or implement a method from a supertype
            @Override 

I have no clue how to override it the right way, as it seems that my Override annotation is completely useless.

I hope you can help me.

0

There are 0 answers