This entry describes the Peg class from this example in further detail:
Public Class Peg
End Class
Properties
The properties of the class are as follows:
Private _Column As Integer
''' <summary>
''' Gets the column of this peg.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Column() As Integer
Get
Return _Column
End Get
Private Set(ByVal value As Integer)
_Column = value
End Set
End Property
The Column property defines the column of the board that contains this peg. The setter is private because once the peg is created, its location cannot be moved.
Private _Correct As Boolean?
''' <summary>
''' Gets or sets whether the peg is in a correct position.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Correct() As Boolean?
Get
Return _Correct
End Get
Friend Set(ByVal value As Boolean?)
_Correct = value
End Set
End Property
The Correct property defines whether this peg denotes a correct answer. A correct answer requires that the peg be of the same color and column position as the correct answer.
Private _PegColor As Color?
''' <summary>
''' Gets or sets the peg color.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property PegColor() As Color?
Get
Return _PegColor
End Get
Set(ByVal value As Color?)
_PegColor = value
End Set
End Property
The PegColor property defines the color of this peg as defined by the user.
Private _Row As Integer
''' <summary>
''' Gets the row containing the peg.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Row() As Integer
Get
Return _Row
End Get
Private Set(ByVal value As Integer)
_Row = value
End Set
End Property
The Row property defines the row of the board that contains this peg. The setter is private because once the peg is created, its location cannot be moved.
Constructor
The following is the constructor defined in the Peg class:
''' <summary>
''' Constructs a new instance in a specific position.
''' </summary>
''' <param name="columnIndex"></param>
''' <param name="rowIndex"></param>
''' <remarks></remarks>
Public Sub New(ByVal columnIndex As Integer, ByVal rowIndex As Integer)
Me.Column = columnIndex
Me.Row = rowIndex
Me.PegColor = Nothing
End Sub
Download the sample code (that is currently only in VB) from here.
Enjoy!