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

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.

主站蜘蛛池模板: 青海省| 伊春市| 霍城县| 德钦县| 宜宾县| 宁南县| 天全县| 保靖县| 西峡县| 泉州市| 新兴县| 桐梓县| 化德县| 中卫市| 那坡县| 萍乡市| 乌拉特后旗| 苏尼特左旗| 德令哈市| 贺州市| 浑源县| 萨嘎县| 从化市| 武夷山市| 乌兰县| 沾化县| 南陵县| 建宁县| 广西| 息烽县| 浑源县| 安溪县| 筠连县| 长白| 丽水市| 清远市| 襄垣县| 泰顺县| 沾益县| 西吉县| 永寿县|