Originally posted by Mac11 thanks for the help.
heres the deal.
the assignment reads: Implement a SavingsAccount class to help keep track of a banks customer account information. Its constructor should take as parameters the customers ame and address, the amount of money in the account and the interest rate.
it tells us to include member functions Deposit, Withdrawal, accumulate, interest, and print_account_info. we are given the interest formula and the interest rate we are supposed to use.
Now the deposit and withdrawl functions are fairly easy. i just added/subtracted the amount from a float variable "balance"
Basicly i have no idea how to go about making the constructor and my book is not much help ive read it like 3 times.
K.. the constructor has a default (no params passed in) but can be defined to allow things to be passed in.. typically those would be used to 'seed' data.. In this case, the client name, initial balance, and interest rate..
I'm not sure why you would have to seed it if you also have to make a method that allows you to change the interest.. other than there is no way to modify the name (not a bad thing in this case, so the constructor would still be a good way to do it)..
So, here might be your definition of the class.. (note that the .... are just for indenting since we can't have various spaces in the messages)
class clAccount_t
{
....private:
..... char _caName[256];
..... char _caAddress[256];
..... float _fInterestRate;
..... float _fBalance;
..... public:
// you might need to 'throw' an exception in here, constructors can't return anything.. if not, you should be ok..
...... clAccount(char *pcName, char *pcAddy, float fInterest, float fBalance)
..... {
........... // error checking, validate input.. make sure name is there, and
........... // the numbers are >= 0 for balance, and >0 for interest
........... sprintf(_caName, "%s", pcName); // note, if it's not a null terminated string you will have to do a memcopy, and have to have the name size passed in..
............ sprintf(_caAddress, "%s", pcAddy);
............ _fInterestRate = fInterest;
............ _fBalance = fBalance;
..... }
..... // not sure if you have to return values from your methods for error checking or not.. but you define them here.. I'll be defining as voids..
..... void vDeposit(float fDepValue);
..... void vWithdraw(float fWithdrawValue);
..... etc etc etc
} // end class
Hope that helps.. If you have any more questions, let me know..
Oh, and since this is all in memory, and if the system goes down you loose your accounts, does the teacher want you to keep track of it on disk? or just make sure after running a few calls of various methods that the final output is right...