Can someone please reply before Tuesday..........I know it is late but cos I had login problems and it only just sorted now.
I am having problems with add traveller into Resort class. I can add traveller fine, but I don't know how to add traveller on home world. I am using Arraylist. Traveller class is abstract class.
private ArrayList<Traveller> travellers = new ArrayList<Traveller>();
private World home = new World("Home", 0, 100);
public void addTraveller(Traveller tr)
{
travellers.add(tr);
}
Also I have problems with finding world that specified traveller is on. It should return world which contains the traveller. I have tried two different code, I bet I done it all wrong. In World class there is traveller ArrayList (private ArrayList<Traveller> traveller = new ArrayList<Traveller>(); ).
private ArrayList<Traveller> travellers = new ArrayList<Traveller>();
private ArrayList<World> worlds = new ArrayList<World>();
public World findTraveller(Traveller tr)
{
for(World temp : worlds)
{
if(temp.getTraveller() == tr)
{
return temp;
}
}
return null;
}
public World findTraveller2(Traveller tr)
{
int index = worlds.size();
return worlds.get(index);
}
If you can help me before Tuesday I would be very very thankful!!