構造函數的參數我有以下的類模型:抽象類與斯卡拉
sealed abstract class Tile(val coordinate: Int, val isOccupied: Boolean) {
def isEmpty() : Boolean
def getPiece() : Option[Piece]
}
case class EmptyTile(coordinate: Int) extends Tile(coordinate, false) {
override def toString: String = "" +coordinate
override def isEmpty() = true
override def getPiece() = None
}
case class OccupiedTile(coordinate: Int, val piece: Piece) extends Tile(coordinate, true) {
override def toString = piece.toString
override def isEmpty = false
override def getPiece = Some(piece)
}
,我得到以下錯誤:
Error:(6, 22) overriding value coordinate in class Tile of type Int;
value coordinate needs `override' modifier
case class EmptyTile(coordinate: Int) extends Tile(coordinate, false) {
^
我在做什麼錯?
編輯:請求看片類,添加在這裏:
import Alliance.Alliance
import PieceType.PieceType
abstract class Piece(val piecePosition: Int, val pieceType : PieceType, val alliance: Alliance) extends Movable {
}
object PieceType extends Enumeration {
type PieceType = Value
val PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING = Value
}
你是什麼斯卡拉的版本? – vptheron
你可以分享你的瓷磚和瓷磚類嗎?這將是有益的REPL它:) –
瓷磚已包括,我會添加件 –