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

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.

主站蜘蛛池模板: 阿克| 岑巩县| 长治市| 内丘县| 霍州市| 文成县| 永城市| 甘洛县| 库尔勒市| 本溪市| 海安县| 武陟县| 仁寿县| 格尔木市| 措勤县| 阿拉善右旗| 盈江县| 铜川市| 许昌市| 凭祥市| 台南县| 徐州市| 罗江县| 阿拉尔市| 和林格尔县| 寻甸| 哈巴河县| 两当县| 高安市| 汪清县| 博野县| 康定县| 行唐县| 黔西县| 太湖县| 武平县| 韶关市| 临沭县| 崇礼县| 太仆寺旗| 南漳县|