How to code method for Saving Account?

qadeer37

Well-known member
Joined
May 1, 2010
Messages
63
Location
Hyderabad,pakistan
Programming Experience
1-3
Private m_HolderName As String
Private m_Balance As Decimal
Private m_Dat As Date = Now
Private m_Intrest As Decimal = CType(m_Balance * 0.1, Decimal)


Private Sub AddIntrest()

'If date is now + 1 month add m_intrest to it
m_Balance += m_Intrest


End Sub

Confused that this approch is correct or not. :confused:
 
My view would be the bank would go around every account each month calling addInterest(), which means you wouldn't need to check if the date is appropriate in the addInterest method. They would also probably pass the interest rate as a parameter for addInterest as the interest rate changes frequently. So you would end up with something like this...

VB.NET:
Private m_HolderName As String
Private m_Balance As Decimal
Private m_Dat As Date = Now

Public Sub AddIntrest(ByVal interestRate as decimal)
    m_Balance += (m_Balance / 100) * interestRate
End Sub

Obviously this is just how I would achieve what I think you're trying to achieve.

Anyway I hoped this helped

Satal :D
 
Back
Top