Thursday, July 30, 2009

What general methods should I use when creating this C++ console application.?

I'm creating a small banking application using C++ that will allow me open up an account, set an over draft limit for a new customer, display/update customer information and show balance by using an account number. Also like to deposit, withdraw.





I'm not looking for code etc, just some pointers. Can someone give me advice on where to start, or how to lay it out. I've done some Java before, but this is something else....





Any help would be greatly appreciated.

What general methods should I use when creating this C++ console application.?
Do it much like Java, except:





include any referenced header files before main, like:


#include %26lt;conio.h%26gt;


otherwise you get errors like "someFunction not defined"





free all allocations manually


otherwise you will get memory leaks





you can use getc or scanf (or others) for input





you can use printf for output, but C++ programmers often use cout like:


cout%26lt;%26lt;"Balance is $"%26lt;%26lt;balance





Hope this helps.
Reply:The most basic things you need to know are input/ouput, reading and writing files, and user-defined functions. After you can make a basic application using those you can try to use classes and templates. If you need more help just e-mail me.
Reply:I'm assuming this is just an academic exercise, or you have a ton more to think about to make this integrate with real banking.





The first thing to figure out is how you are going to represent the account and its data (including balance, overdraft limits, customer data, etc). You probably want to define a class to store the account data, with functions to access and modify the data -- get balances, modify balance, analyze overdraft rules, etc. The account rule logic can all be encapsulated in this class.





Once you've defined a class to represent the AccountInfo, think about how you'll represent the collection of accounts so you can easiliy find the account when the user requests an action on it. An STL map may be a good bet for storing your accounts for easy lookup. The key could be the account number, and the value could be your AccountInfo class.





You might also think about how you will create a new account and verify that the data entered is valid. Maybe you want an AcctManager class to do that. It will need to create a new account number and make sure it doesn't already exist in the account collection, make sure all required account data is present and valid, create the AccountInfo class and save the to the account collection. Maybe AcctManager owns the AccountInfo collection.





Do these accounts need to persist when the application stops? I'm guessing not.





Good luck!


No comments:

Post a Comment