Quantcast

Maximum PC

It is currently Sun Nov 23, 2014 3:54 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: C++ Project to help me remember all I have forgotten...
PostPosted: Thu Dec 11, 2008 5:56 am 
Monkey Federation (Top 10)*
Monkey Federation (Top 10)*
User avatar

Joined: Sun May 22, 2005 8:28 am
Posts: 3673
Location: The Blue Nowhere
I have not taken a programming class since May and my skills (what littler there were) are dwindling at an alarming rate. Sooo, with the end of the semester coming up I want a programming project to keep me busy during the break. I have an idea for a personal project and would like some help defining the scope of my program. I have taken a few C++ classes so am not a newb but I am far from being called proficient in any form of the word.

What I would like to do is write a program that will allow me to keep track of multiple bank accounts (add, remove, update) and save the information to a simple text file. Later, I am going to make this write to a database and add more functionality; that is down the road...

I am assuming each account would be an instance of a class object. What I would like are ideas on how to setup the classes. I am OK with inheritance as long as it does not get too complicated.

I am starting to think about what properties to put in the classes first, should I be starting somewhere else.

I will need:
bankName
accountNum
curBalance
amtDeposit
amtWithdrawl
curDate // I am thinking about adding a history function later

I would like to practive using hash tables as well and was thinking about mapping bankname to accountNum or vice versa.

Give me some feedback and let me know what you think. Am I on the right track? Off my rocker? This is planning, actual work will not start until after the semester ends on 12/17 so there is plenty of time for analysis and design.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2008 10:11 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24236
Location: Granite Heaven
You're definitely on the right track.

Here is how I would break the project down initially:

First, you need to define a generic bankAccount object. This definition should include both how you describe the object (its attributes) and how the object acts (its methods).

Account Attributes
Lets start with the list of attributes you've provided and I'll give you my opinion.

These are the variables that I would use in the object:

bankName
accountNum
balance -- I've renamed this because you are only interested in the current balance. Previous balances will be stored in your history file.

I would not define curDate in the object because the date and the object are independent. Any time you need the date, you can pull it from the system.

Similarly, these two (amtDeposit, amtWithdrawl) are not needed. They are specific to individual transactions and should be recorded as such.

Additional variables / attributes:
ownerName - string to hold the name of the account holder
otherUsers[] - an array of strings that hold the names of other people with access.

You could create a User object instead, with all the user info (address, phone number, age, accounts to which they have access) but this may add complexity that you don't need.

Account methods
getXXXX
setXXXX ... these are generic get and set methods. They return the value of the current balance, ownerName, etc.. Every mutable attribute needs get and set methods to ensure that the object is always responsible for its own maintenance.

Inheritence

All the things that make a chequing account different from a saving account are defined in the inherited classes. So a savings account will have an interest rate while a chequing account may override the setBalance() method to include a date (so you can write post-dated cheques and have your account updated appropriately on the day the cheque is to be cashed).

I hope that helps .. I feel I've been rambling a bit. ;)


Top
  Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2008 5:43 pm 
8086
8086
User avatar

Joined: Sat Dec 06, 2008 11:57 pm
Posts: 3
An easy way to read and write to a database is to use the .csv filename extension (comma separated value). This will read and write to Excel, and a comma (",") will be the cell delimiter.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.