So I've got another project due soon, and little time to do it, so I figured I might beg for yourhere
Situation:
1 superclass DiskItem
3 subclasses File, Directory and Link
I have to write the Link class, the problem is that the name you can give to Directory and a File obeys different rules, and the Link has to follow the rules of the DiskItem it refers to, but since it is a subclass it has to use the superconstructor, which doesn't account for a reference when giving names.
Is there any way around this without making a new DiskItem constructor especially for the subclass ?
2nd question:
The Link refers to a DiskItem, but you shouldn't be able to access/alter the DiskItem from the Link (so no link.getReference().changeName or things like that). How do you do this ? I've been looking at the cloneable interface but the info given by Sun is vague to say the least. It would also seem like this would create a new item to be returned, which would be bad since then I'd essentially have the same DiskItem twice in a Directory. I could make a new class DiskItemClone, but that seems a little unpractical.
So can somebody give me some?
Bookmarks