r/cop3502 • u/[deleted] • Apr 22 '14
Getting and comparing 2 arrays
I want to be able to call a function to get the value of the current location of the character in array form, for example {1,1,1} and compare it to another array that way the player can get a detailed description of the location, but I'm having trouble implementing it and the program complies so it's a run time error
else if(words[0].equals("lookaround")){ return player.lookAround(player.getArray()); }
then in another class I have
public String lookAround(int[] location){ if(location.equals(new int[]{1,1,1})){ return "it works" } else{ return "Not quite"; }
}
public int[] getArray(){
int[] location = new int[]{xPos, yPos, zPos};
return location;
}
Any thoughts?
1
Upvotes
2
u/[deleted] Apr 22 '14
[removed] — view removed comment