I'm working with a school project and got one tiny little thing left before I can hand in in 30 mins!
I have a map, where I can put places on! These places have x and y coords. I can hide these places and then I have a button and after that I can click my map if there is any place hiding there. The thing is I can't get it to work.
I have a hashmap that takes my position class as a key and the place as a value.
I get my x and y from where I click and I wanna check if my position map contains that.. Here is my code so far
class WihMouseLis extends MouseAdapter{
@Override
public void mouseClicked(MouseEvent mev){
int x = mev.getX();
int y = mev.getY();
if(posMap.containsKey(new Position(x,y))){
System.out.println("TEST! did i hit it?");
}
}
}
is there any other way or am I doing it wrong! I have done my own equals and hashCode method in my position class!
Aucun commentaire:
Enregistrer un commentaire