0

私はチェス ゲームに元に戻す/やり直しメカニズムを設計しようとしています..ArrayList に構築されるスタック データ構造を使用することにしました..また、UndoStack クラスと RedoStack クラスをシングルトンにする必要があります..しかし、私は取得しています

method does not override or implement a method from a supertype

pop() in UndoStack cannot implement pop() in IStackable
  return type Move is not compatible with cgas5.Move
  where Move is a type-variable:
    Move extends Object declared in class UndoStack

エラー..

ここに私の ISt​​ackable インターフェイスがあります:

package cgas5;


public interface IStackable {

    abstract public Move pop();

    abstract public void push(Move m);

}

と私の UndoStack クラス

package cgas5;

import java.util.ArrayList;

public class UndoStack<Move> extends ArrayList<Move> implements IStackable {

    UndoStack undoStack;

    private UndoStack() {
        undoStack = new UndoStack();
    }

    public UndoStack getUndoStack() {
        if (undoStack == null) {
            undoStack = new UndoStack();
        }
        return undoStack;
    }

    @Override
    public Move pop() {
        Move m = get(size() - 1);
        remove(size() - 1);
        return m;

    }

    @Override
    public void push(Move m) {
        add(m);
    }
}

必要に応じて、Move クラス:

package cgas5;

public class Move {
    private Piece pieceToMove;
    private Square currentSquare;
    private Square targetSquare;
    private Piece capturedPiece;
    private Piece promotedPiece;

    public Move(){

    } 

    public Move(Piece pieceToMove, Square currentSquare, Square targetSquare){
        this.pieceToMove = pieceToMove;
        this.currentSquare = currentSquare;
        this.targetSquare = targetSquare;
    }

    public Piece getPieceToMove() {
        return pieceToMove;
    }

    public void setPieceToMove(Piece pieceToMove) {
        this.pieceToMove = pieceToMove;
    }

    public Square getCurrentSquare() {
        return currentSquare;
    }

    public void setCurrentSquare(Square currentSquare) {
        this.currentSquare = currentSquare;
    }

    public Square getTargetSquare() {
        return targetSquare;
    }

    public void setTargetSquare(Square targetSquare) {
        this.targetSquare = targetSquare;
    }

    public Piece getCapturedPiece() {
        return capturedPiece;
    }

    public void setCapturedPiece(Piece capturedPiece) {
        this.capturedPiece = capturedPiece;
    }

    public Piece getPromotedPiece() {
        return promotedPiece;
    }

    public void setPromotedPiece(Piece promotedPiece) {
        this.promotedPiece = promotedPiece;
    }

}

前もって感謝します..

4

1 に答える 1