Time for action – GamePiece class methods – part 1 – updating
Add the following methods to the
GamePiece
class:Public Sub SetPiece(type As String, suffix As String) _pieceType = type _pieceSuffix = suffix End Sub Public Sub SetPiece(type As String) SetPiece(type, "") End Sub Public Sub AddSuffix(suffix As String) If Not _pieceSuffix.Contains(suffix) Then _pieceSuffix &= suffix End If End Sub Public Sub RemoveSufix(suffix As String) _pieceSuffix = _pieceSuffix.Replace(suffix, "") End Sub
The first two methods are overloads with the same name, but different parameter lists. In a manner similar to the
GamePiece
constructors, code that wishes to update aGamePiece
can pass it a piece type and, optionally, a suffix.Additional methods have been added to modify suffixes without changing the
pieceType
associated with the piece. TheAddSuffix()
method first checks to see if the piece already contains the suffix. If it does, nothing happens. If it does not, the suffix value passed...