It depends on where your survivor is. Your zombie will need a link to Survivor somewhere - what is it for? Who should be responsible for providing this?
, Gui , , - GameState, , Gui . , , getSurvivor() Gui/Gamestate - Zombie, , , . GameState , .
: - :
public class Zombie
{
private final Gui guiThatMadeMe;
public Zombie(Gui owner)
{
guiThatMadeMe = owner;
}
....
public void move()
{
Survivor guy = guiThatMadeMe.getSurvivor();
}
}
public class Gui
{
private Survivor lonelyGuy;
...
public Survivor getSurvivor()
{
return lonelyGuy;
}
public void createNewGame()
{
lonelyGuy = new Survivor();
for (int i = 0; i < NUM_ZOMBIES; i++)
{
Zombie zombie = new Zombie(this);
}
}
}
, , , . , , . , , .