官术网_书友最值得收藏!

Time for action – building a GamePiece class – constructors

  1. Add two constructors to your GamePiece.vb file after the declarations:
    Public Sub New(type As String, suffix As String)
      _pieceType = type
      _pieceSuffix = suffix
    End Sub
    
    Public Sub New(type As String)
      _pieceType = type
      _pieceSuffix = ""
    End Sub

What just happened?

A constructor is run when an instance of the GamePiece class is created. By specifying two constructors, we will allow future code to create a GamePiece, by specifying a piece type with or without a suffix. If no suffix is specified, an empty suffix is assumed.

Updating a GamePiece

When a GamePiece is updated, you can change the piece type, the suffix, or both.

主站蜘蛛池模板: 瓮安县| 东乡| 新余市| 吴江市| 泰顺县| 建瓯市| 余干县| 尉氏县| 建德市| 方山县| 融水| 龙陵县| 象州县| 孟州市| 岱山县| 罗甸县| 桦甸市| 肃北| 蓬莱市| 东光县| 积石山| 九江市| 兴海县| 茶陵县| 喀喇沁旗| 都兰县| 安福县| 皋兰县| 淮滨县| 吉木萨尔县| 崇义县| 关岭| 开化县| 沁阳市| 灵宝市| 隆昌县| 炉霍县| 曲松县| 花莲县| 南皮县| 柳河县|