0
Access problems
So the mission is to access class Book for main (not a problem), then access defined in main variables of the Book in method next() of class Display and use the method in main. Book-Database-Display-Database e g class Book { int pages;} class Database { main { Book b= new Book; b.pages = 42; next(); }} class Display { static int next() { return b.pages++;}} I can willingly tell errors that I had using different options
8 Respostas
+ 2
You need to pass the book object in display class. For instance in constructor or use a setter method.
+ 1
I have plenty of them passed in main. Variables are assigned to each one. The problem lays in lack of method's access to main.
The ideal would be to declare the method in main, but errors tell me that I can't do so.
+ 1
Sorry?
0
Why don't you implement the next method in your Book class non static?
Do you really need Display class?
0
I have some attributes defined there
0
I think you need a pointer to the current Page. From your code I cannot See.
0
I started an example you can find in my stuff.
0
Sorry, I'll answer you tommorow. I'm falling asleep.
You might give a brief look at the actual code I uploaded.