Well, I have a thing for school due Monday but I'm having a little trouble with it. The project or solution consists of a form and a class. My professor wanted us to transfer all the math to the class and leave the other code in the form, needless to say it's easier said than done.
I am not very experienced with using classes yet and want to accumulate totals that the user has ended up with. Do the variables in the class have to be declared differently than in the form?
Here is what I have so far, it would be great if I could get some much needed help with this.
Right now only the sumTotalComm works correctly...
Public Class SalesPerson
Const QUOTA_Decimal As Decimal = 1000D
Const COMMISSION_RATE_Decimal As Decimal = 0.15D
Const BASE_PAY_Decimal As Decimal = 250D
Private salesString As String
Private weeklySalesLessDecimal As Decimal
Private Shared weeklySalesDecimal, sumTotalCommDecimal, _
totalSalesDecimal, commDecimal, sumTotalPayDecimal, totalPayDecimal As Decimal
Private weeklyDecimal As Decimal
Private Shared sumTotalWeeklyDecimal As Decimal
'Parameterized constructor.
Sub New(ByVal Sales As String, ByVal Weekly As Decimal)
'Assign the property values.
With Me
.Sales = Sales
.Weekly = Weekly
CalculateComm()
CalculateWeeklySalesLess()
CalculateWeekly()
CalculateSumTotalComm()
CalculateSumTotalWeeklyDecimal()
End With
End Sub
Property Sales() As String
Get
Return salesString
End Get
Set(ByVal value As String)
salesString = value
End Set
End Property
Property TotalWeekly() As Decimal
Get
Return sumTotalWeeklyDecimal
End Get
Set(ByVal value As Decimal)
CalculateSumTotalWeeklyDecimal()
End Set
End Property
Property SumTotalComm() As Decimal
Get
Return sumTotalCommDecimal
End Get
Set(ByVal value As Decimal)
CalculateSumTotalComm()
End Set
End Property
Property Weekly() As Decimal
Get
Return weeklyDecimal
End Get
Set(ByVal value As Decimal)
If value >= 0 Then
weeklyDecimal = value
End If
End Set
End Property
Property WeeklySalesLess() As Decimal
Get
Return weeklySalesLessDecimal
End Get
Set(ByVal value As Decimal)
If weeklySalesDecimal < 1000 Then
CalculateWeeklySalesLess()
End If
End Set
End Property
Property Comm() As Decimal
Get
Return commDecimal
End Get
Set(ByVal value As Decimal)
commDecimal = value
End Set
End Property
Protected Overridable Sub CalculateComm()
'please calculate commission.
commDecimal = weeklyDecimal * COMMISSION_RATE_Decimal
End Sub
Protected Overridable Sub CalculateWeeklySalesLess()
weeklySalesLessDecimal = BASE_PAY_Decimal
End Sub
Protected Overridable Sub CalculateWeekly()
weeklyDecimal = (weeklyDecimal * COMMISSION_RATE_Decimal) + 250
End Sub
Protected Overridable Sub CalculateSumTotalWeeklyDecimal()
sumTotalWeeklyDecimal = weeklyDecimal
End Sub
Protected Overridable Sub CalculateSumTotalComm()
sumTotalCommDecimal += commDecimal
End Sub
End Class