Patricia

Patricia

TMA MT264 02
Question 1
Public Class TicketAdmin
Dim fProductions As New Dictionary(Of String, Integer)

Public ReadOnly Property Productions As Dictionary(Of String, Integer)
Get
Return fProductions
End Get
End Property

Public Sub New()
fProductions = New Dictionary(Of String, Integer)
fProductions.Add("Carmen", 0)
fProductions.Add("Don Giovanni", 0)
fProductions.Add("How The Whale Became", 0)
fProductions.Add("Manon", 0)
fProductions.Add("Peter Grimes", 0)
End Sub
Public Sub incrementCount(ByVal Production As String)
If Productions.ContainsKey(Production) Then
fProductions.Item(Production) = Productions.Item(Production) + 1
End If
End Sub
End Class


Question 2
This question is based on Unit 5.
For index As Integer From 0 To (wordArray.Length − 1)
The for loop is started by using the For keyword. This tells Visual Basic 2010 that you want to create
a loop. Everything that follows the For keyword is used to define how the loop should act. In this case,
you’re giving it the variable you just created and then telling it to count from 1 to 5:
The variable that you give the loop (in this case, intCount) is known as the control variable. When you
first enter the loop, Visual Basic 2010 sets the control variable to the initial count value — in this case, 1.
After the loop starts, Visual Basic 2010 moves to the first line within the For loop — in this case, the line
that adds a string to the list box:

This time, this line of code adds I’m item 2 in the list! to the list box. Again, after this line is executed,
you run the Next statement. The value of intCount is now incremented from 2 to 3, and because 3 is less
than or equal to 5, you move back to the line that adds the item to the list. This happens until intCount is
incremented from 5 to 6. Because 6 is greater than the stop value for the...

Similar Essays