how do i fix this? "p" is an array in another class.
Stevens Miller wrote:You said p is in another class. You'll need an instance of that class and some way to access its members, either with a "getter" method (that's the preferred way) or by direct access (generally frowned upon).
how would i go about doing that??? I understand the term, just am foggy... been doing his project for 6 hours straight now.
Note that accessing other classes purely via static methods (as the code does now) is not good object oriented design. you should consider instantiating objects in the "Main" class, and then calling methods on those objects.
Ulf Dittmer wrote:Well, in which class is it? "Printer" or "Database"? Or some other class?
Note that accessing other classes purely via static methods (as the code does now) is not good object oriented design. You should consider instantiating objects in the "Main" class, and then calling methods on those objects.
p is in database
I also suspect that your "p" variable is supposed to be a Person object. You don't have it declared in the main method.
Never mind about posting your Database and Person classes. I see you did that in another thread.
In the other thread you had a method "handleAddPerson" that's not in this listing. That was almost where you want to be. You just didn't add the Person object to the Database object. In this thread you don't have that method, but you're trying to add "p" to the database but it isn't declared as a Person object, nor do you get any data for it.