I haven't included the main function since it's empty.I am trying to access the private variable name from my parent class to the child class but then it throws an error message.It would be nice if you could help me out.I am new to JAVA btw.
public class Author {
private String name;
private String email;
private char gender;
public Author(String name,String email,char gender)
{
this.name=name;
this.email=email;
this.gender=gender;
}
protected String getName()
{
return name;
}
//protected String
}
public class Book extends Author {
private String name;
private String authorname;
private double price;
private int qtyInStock;
Book(String name,Author a,double price,int qtyInStock)
{
this.name=name;
this.authorname=a.getName(); //Error
this.price=price;
this.qtyInStock=qtyInStock;
}
}
Error Message:
Implicit super constructor HelloWorld.Author() is undefined. Must explicitly invoke another constructor.