I have the following code for entering loops:
public void play()
{
System.out.println(toString());
while(player.getPosition() != exit.getPosition() && itemsCollected() == false ){
turn();
System.out.println(toString());
if(difficulty=='h'){
if(e1.getPosition()==player.getPosition()){
System.out.println("Ouch! You were eaten. ");
System.exit(0);}
else if(e2.getPosition()==player.getPosition()){
System.out.println("Ouch! You were eaten. ");
System.exit(0);}
}
}
The part in bold does not work, because whenever it runs the loop will cease execution when player.getPosition() = exit.getPosition even if items collected = false, and i cant figure out why?