Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 18th, 2007, 06:53 PM
Cyclone_B Cyclone_B is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 2 Cyclone_B User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 13 m 14 sec
Reputation Power: 0
Child Objects Sharing Memory With Parent

Hello,

I'm pretty new to java, so I'm pretty frustrated with this. I am creating a banking type system with the parent "Account" class having most of the banking operations (deposit, withdraw, view balance) and the "Checking" and "Savings" classes inheriting from the account class with their own specific operations.

My assignment says to create 1 object of account and 2 each of checking and savings. I declare them as

Object account 1 = new Account()
Object checking1 = new CheckingAccount( )
Object checking2 = new CheckingAccount( )
...and so on
Everything works fine until I actually attempt to put in information into the classes. For example, no matter which account of the 5 I deposit money to, they all show that money has been added. I don't exactly get why they would all share the same memory space, but I'm sure it's something I did wrong. Any help would be greatly appreciated.

Reply With Quote
  #2  
Old March 27th, 2007, 06:01 PM
daniel_g daniel_g is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 60 daniel_g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 3 m 50 sec
Reputation Power: 3
I'm sorry if the reply is too late, but it's impossible to figure out the problem given the stuff you have posted. I suppose you have 3 classes:
Account
CheckingAccount
SavingAccount

And Checking and Saving accounts must either have their own local variables, or your class Acount must have 4 variables(which is less likely). So I don't really see why modifying one class would affect the others.

Can you post at least the part where you add the money?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Child Objects Sharing Memory With Parent


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT