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

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.

主站蜘蛛池模板: 东方市| 大荔县| 五大连池市| 鲁甸县| 新郑市| 昌平区| 沧源| 潮安县| 深泽县| 淮北市| 象州县| 阳曲县| 临江市| 保靖县| 府谷县| 岳池县| 岳阳县| 宁陵县| 万载县| 安溪县| 菏泽市| 无为县| 遂昌县| 新巴尔虎左旗| 广河县| 平罗县| 玛多县| 安徽省| 宁蒗| 香港| 平谷区| 白山市| 大同市| 宝兴县| 友谊县| 霍邱县| 哈巴河县| 东宁县| 宁武县| 专栏| 雷山县|