I am trying to set the value of the property so if the account goes into debit there is a fee of 10 is charged. I've tried coding the property CurrentBalance in a number of ways including debit(10), value -10 and accountbalance-10 but none of these approaches work. The code compiles but does not charge a fee. What am I doing wrong?
public void Credit(decimal amount)
{
accountBalance += amount; //add to balance
}
public void Debit(decimal amount)
{
accountBalance -= amount; //subtract amount
}
public decimal CurrentBalance
{
get
{
return accountBalance;
}
set
{
if (value < 0) // if less than zero debit account by 10
{
value = accountBalance -10; // charge account
}
accountBalance = value;
}
}