MarkK
bit cruncher
- Local time
- Today, 14:21
- Joined
- Mar 17, 2004
- Messages
- 8,498
Then, if you have a cTaxEngineFederal class, it might look like...
So this allows for runtime selection of an appropriate provincial tax calc strategy based on runtime data. And it keeps your code really tidy because each provincial strategy is discretely encapsulated in snap-in class expressly and independently developed and tested.
Code:
Private stg_ As Object
Private year_ As Long
Private fedTax_ As Currency
Private prvTax_ As Currency
Sub Init(Year As Long, Province As String)
year_ = Year
Set stg_ = GetTaxStrategy("Calc" & Province & "Tax")
End Sub
Sub CalcTotalTax()
fedTax_ = CalcFedTax
prvTax_ = stg_.Execute(fedTax_)
MsgBox "Total Tax is " & fedTax_ + prvTax_
End Sub
Private Function CalcFedTax() As Currency
' returns federal tax
End Function