Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 28,087
- Reaction score
- 17,859
I guess there are several ways to do this however I'm a little lost as to the most effective approach.
I have two classes lets call them SavingsAccountHelper and CurrentAccountHelper.
This is the interface for both.
public interface IAccountHelper
{
void Deposit(string accountId, decimal amountToDeposit);
void OpenAccount(string accountId);
void Withdraw(string accountId, decimal amountToWithdraw);
}
Additionally there are two classes, Savings and Current but lets work with Savings account for now which has the following properties;
public string accountId{ get; set; }
public string CustomerNumber { get; set; }
public decimal TotalBalance { get; set; }
I have put these two classes together already, performing all of those functions. My confusion is this, say you instantiate one of these classes:
SavingsAccountHelper accounthelper = new SavingsAccountHelper();
Question: What is the best way to perform the a SavingsAccountHelper functions against an account and get the new values out again? What I did initially was pass an account reference into the constructor:
SavingsAccount account = new SavingsAccount(1,DF445454,24565);
SavingsAccountHelper accounthelper = new SavingsAccountHelper(account);
The problem I am having with this approach, or not so much a problem, but it feels wrong, is getting the values out again. If someone deposits 12500 into the account, what is the best way to retrieve the new balance?
accounthelper.Deposit(accountId,12500)
I have two classes lets call them SavingsAccountHelper and CurrentAccountHelper.
This is the interface for both.
public interface IAccountHelper
{
void Deposit(string accountId, decimal amountToDeposit);
void OpenAccount(string accountId);
void Withdraw(string accountId, decimal amountToWithdraw);
}
Additionally there are two classes, Savings and Current but lets work with Savings account for now which has the following properties;
public string accountId{ get; set; }
public string CustomerNumber { get; set; }
public decimal TotalBalance { get; set; }
I have put these two classes together already, performing all of those functions. My confusion is this, say you instantiate one of these classes:
SavingsAccountHelper accounthelper = new SavingsAccountHelper();
Question: What is the best way to perform the a SavingsAccountHelper functions against an account and get the new values out again? What I did initially was pass an account reference into the constructor:
SavingsAccount account = new SavingsAccount(1,DF445454,24565);
SavingsAccountHelper accounthelper = new SavingsAccountHelper(account);
The problem I am having with this approach, or not so much a problem, but it feels wrong, is getting the values out again. If someone deposits 12500 into the account, what is the best way to retrieve the new balance?
accounthelper.Deposit(accountId,12500)
Last edited: