+ 2
Overriding class attributes
is there a way to override class attributes? For example: if you have a parent class 'Book', and you had a subclass 'eBook' that extends Book. Now, let's say Book has nPages for the amount of pages in the physical book. ebook however has fileSize in place of physical pages. Is it possible to override the parent attribute and replace it with the subclass version? I've been hiding the unused attributes when calling the superclass as the workaround. Thanks in advance!
1 Odpowiedź
+ 2
ahhh, gotcha. So my issue was simply a problem with abstraction and trying to force a paper attribute, and create a workaround for other classes that depend on the book superclass.
Thanks for your input. I thought it was a java issue that I wasn't familiar with.