2021 - BarronPiece

From TRCCompSci - AQA Computer Science
Revision as of 09:23, 3 September 2020 by Admin (talk | contribs) (Created page with "=Actual Code= <syntaxhighlight lang=c#> class BaronPiece : Piece { public BaronPiece(bool player1) : base(player1) { pieceType...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Actual Code

    class BaronPiece : Piece
    {
        public BaronPiece(bool player1)
            : base(player1)
        {
            pieceType = "B";
            VPValue = 10;
        }

        public override int CheckMoveIsValid(int distanceBetweenTiles, string startTerrain, string endTerrain)
        {
            if (distanceBetweenTiles == 1)
            {
                return fuelCostOfMove;
            }
            return -1;
        }
    }

Things to note

Constructor runs the base constructor as well as setting peiceType & VPValue.

CheckMoveIsValid is overriden in this sub class.