Im having trouble with this book class extending from a publication abstract class which extends from a publishable interface class. however when i try to compile it bring up the error message "cannot reference publicationDate before supertype constructor has been called"
This is my Book class code:
public abstract class Book extends Publication
{
/**
* Set the attributes inherited from the publication class
*/
public Book (String publicationDateIn, boolean subscriptionIn, String subscriptionLengthIn, int pageNumbIn,
String publisherNameIn, String publicationTitleIn, float priceIn, String publicationTypeIn, String issnNumbIn
, int authorNumbIn)
{
super (publicationDate, subscription, pageNumb, publisherName, publicationTitle, price, publicationType, subscriptionLength, authorNumb, issnNumb);
}
}
I'm assuming your
Publication
class has apublicationDate
field (and all the other ones you have there). You can't reference that field in a sub type constructor until thesuper
constructor has been invoked.Did you mean to have
? In other words, you weren't using your constructor parameters, you were using the parent class' fields.