Storing Objects

Reply

Join Date: Oct 2007
Posts: 59
Reputation: Grub is an unknown quantity at this point 
Solved Threads: 0
Grub Grub is offline Offline
Junior Poster in Training

Storing Objects

 
0
  #1
Oct 25th, 2007
Hi, I have a project on which I am working.
I have two classes. A box Class which is of an undefined capacity and is only defined when an instance of the box class is made and I have an item class of which instances of it must be stored in the box. How might I represent this. Particularly When I create an Item how do I store it in the box as I may have to make more than one item per box created. I should also be able to subtract item from the box.

My attempt had me make an item array in the box class does that seem wrong. It does to me.

Any help would be appreciated.


Many thanks
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,277
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 242
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Storing Objects

 
0
  #2
Oct 25th, 2007
Use an ArrayList (this is dynamic whereas an array is fixed length).
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC