''' <summary>
''' A collection to store multiple <see cref="Die" /> objects.
''' </summary>
Public Class DieCollection
Inherits System.Collections.ObjectModel.Collection(Of Die)
#Region " Constructors "
''' <summary>
''' Creates a new, empty instance of the <see cref="DieCollection" /> class.
''' </summary>
Public Sub New()
End Sub
''' <summary>
''' Create a new instance of the <see cref="DieCollection" /> with the specified number of items.
''' </summary>
''' <param name="dieCount">
''' The initial number of items in the collection.
''' </param>
''' <remarks>
''' The initial items all have the default number of faces, as defined by the <see cref="Die.DefaultFaceCount" /> field, and use the default random number generator.
''' </remarks>
Public Sub New(dieCount As Integer)
For i = 1 To dieCount
Items.Add(New Die)
Next
End Sub
''' <summary>
''' Create a new instance of the <see cref="DieCollection" /> with the specified number of items.
''' </summary>
''' <param name="dieCount">
''' The initial number of items in the collection.
''' </param>
''' <param name="faceCount">
''' The number of faces each die has.
''' </param>
''' <remarks>
''' The initial items all use the default random number generator.
''' </remarks>
Public Sub New(dieCount As Integer, faceCount As Integer)
For i = 1 To dieCount
Items.Add(New Die(faceCount))
Next
End Sub
''' <summary>
''' Create a new instance of the <see cref="DieCollection" /> with the specified number of items.
''' </summary>
''' <param name="dieCount">
''' The initial number of items in the collection.
''' </param>
''' <param name="randomNumberGenerator">
''' The object used to select a die face.
''' </param>
''' <remarks>
''' The initial items all have the default number of faces, as defined by the <see cref="Die.DefaultFaceCount" /> field.
''' </remarks>
Public Sub New(dieCount As Integer, randomNumberGenerator As IRandomNumberGenerator)
For i = 1 To dieCount
Items.Add(New Die(randomNumberGenerator))
Next
End Sub
''' <summary>
''' Create a new instance of the <see cref="DieCollection" /> with the specified number of items.
''' </summary>
''' <param name="dieCount">
''' The initial number of items in the collection.
''' </param>
''' <param name="faceCount">
''' The number of faces each die has.
''' </param>
''' <param name="randomNumberGenerator">
''' The object used to select a die face.
''' </param>
Public Sub New(dieCount As Integer, faceCount As Integer, randomNumberGenerator As IRandomNumberGenerator)
For i = 1 To dieCount
Items.Add(New Die(faceCount, randomNumberGenerator))
Next
End Sub
#End Region 'Constructors
#Region " Methods "
''' <summary>
''' Rolls all the dice in the collection and returns the sum of the results.
''' </summary>
''' <returns>
''' An <b>Int32</b> containing the summed values of all dice.
''' </returns>
Public Function RollAll() As Integer
Return Items.Sum(Function(die) die.Roll())
End Function
#End Region 'Methods
End Class