Public Class ActivityStoppedState
inherits ActivityState
'Not from other state.
Public Sub New(activity As IActivity, employee As IEmployee)
Me.Activity = activity
CurrentEmployee = employee
End Sub
'From other state.
Public Sub New(state As ActivityState)
Activity = state.Activity
CurrentEmployee = state.GetEmployee()
End Sub
'''
Public Overrides Function ActivityStateEnum() As ActivityStateEnum
Return ProductiePitching.ActivityStateEnum.Stopped
End Function
'''
Public Overrides Function GetEmployee() As IEmployee
Return CurrentEmployee
End Function
'''
Public Overrides Sub StartActivity(employee As IEmployee)
If IsNothing(employee) Then
'Nothing employee.
Throw New Exception($"The employee can't be nothing when starting an activity from stopped state.")
End If
'Update employee.
employee.CurrentActivity = me.Activity
'Everyone can start this activity.
Activity.State = New ActivityStartedState(Me, employee)
End Sub
End Class