• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array assistance and method confusion  RSS feed

 
Corey Hartman
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to have the code below, pass the data typed in by the user passed to the following method:

public void addPerson(Person p)
{
personList.add(p);
}
and it must be from there added to the array "personList" that is in databse.java (which is posted at the very bottom.

This is what i have so far:


here is Person.java for those who wondered.



and here is database.java


 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, but did you have a question? All I see is "I need to do <something>", and about 150 lines of code. You'll find you get a much better response around here if you TellTheDetails.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Were you given any of this code? I can see many problems with it. I would suggest you sort out the Person class first. You have a constructor which leaves the object in an inconsistent state, minus name etc. Start by giving it a constructor which requires name etc. as parameters and initialises all those fields to real values. You have a constructor which takes parameters, but doesn't do anything. You have another constructor which takes no parameters. Delete that. Consider whether any of those fields should ever change; if not, remove their setXXX methods. The getAge method (if it will actually compile) is hiding a serious logic error. Give that class a toString method, and get that working. Then consider the List later.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!