I am currently writing a program but I found a problem. The problem is that in this loop below all instances of the class Person are attached to one instance of Item. What I want is that a Person each have his own Item. Do you have any suggestions?
Class simulate:
public void simulate(int days){
for(int i=0;i<days;i++) {
int persons = 10;
for(int j=0;j<persons;j++){
Person person = new Person();
Item item = new Item();
person.setItem(item);
}
}
}
Class Person:
private Item item;
public void setItem(Item item)
{
this.item = item;
}