So i have a paper publication class with protected variables and its own package.
Then i have a book class that extends paper publication. This book class then has 3 classes that extend book class (all three same package)
the book class has protected variables and the extended book classes have package private.
Now when i create a driver in a new class with its own package I cannot call any variable directly
package paperPublication;
public class PaperPublication {
protected String title;
protected double price;
package book;
import paperPublication.PaperPublication;
public class Book extends PaperPublication {
protected long ISBN;
protected int issueYear;
package book;
public class ChildrenBook extends Book {
int minimumAge;
Then my driver class which screws it all up... and i get why since its in its own package/class. but.... i cant seem to wrap my head around how to get this to work properly
package driver;
import book.*;
import paperPublication.PaperPublication;
public class Driver{
public static void main(String[] args) {
// TODO Auto-generated method stub
Book a = new Book();
System.out.println(a.ISBN);
System.out.println(a.title);
isbn and title cannot be retrieved... make public. ;( which is not what i want. Also i have all constructors already.
the purpose of my project is to use protected,public,private,package private ints,strings etc... using inherentance and test the privacy by creating objects and calling straight variables like book.title or book.isbn from variables stored in constructors in a main method