I'm trying to create one instance of a file type (txt, jpg, doc, etc...). I have an inheritance structure that goes something like this.
abstract FileClass <- superclass
JPG DOC TXT <- (child classes)
Ignore the fact that this example doesn't seem very practical, it's more for just learning inheritance. I have a swing menu where I can select to load, or save any of these child classes.
If I load up a JPG file I want to keep track of the files name, size, and keep a File object of it. If I then click on the DOC menu and select save, I want it be able to use the file object that was created when I loaded the JPG file.
In my menu class I have a reference to the FileClass (superclass), and have methods for each menu operation (a load/save method for each subclass). The problem is each menu option creates a new subclass object with a superclass reference. So it creates a new object each time a menu option is selected, which means I lose all the information of a loaded file if I choose to save it.
Ex
menuclass
[ September 23, 2006: Message edited by: Bob Zoloman ]