I have a list with an amount of "turtles" created. This is just some of the code, not all.
int nrTurtles = Keyboard.nextInt("How many turtles to create: ");
w = new GraphicsWindow(500, 300);
for (int k = 1; k <= nrTurtles; k++) {
Turtle t = new Turtle(w, 50, 50 + 10*k);
turtles.add(t);
}
And each turtle has a coordination value that i can get with (example):
turtles.get(0).getX() //this gets turtle nr 1 position
Now how do i on a smart way check if two or more turtles depending on how many there are in the list has the same coordination value ( a fix value of 450)?
And if two or more has the same value (450) i want to write with system.out.print that "turtle1 and turtle2 are the ones", if it happens that turtle1 and turtle2 has the same value.
If there is only one turtle having the value of (450) and no other, i want to write only that turtle, for ex. "turtle1 is the only one".
Turtleclass have theequals()method implemented?