import java util ArrayList import java util Random public class Map pr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.ArrayList;
import java.util.Random;
public class Map {
private ArrayList<Vector2D> food;
private ArrayList<Fish> fish;
private Random random = new Random();
public Vector2D getNearestFood(Vector2D point)
{
double minDistSqr = Double.MAX_VALUE;
Vector2D result = null;
for(Vector2D foodPiece: food){
double distSqr = point.sub(foodPiece).absSqr();
if(distSqr < minDistSqr){
minDistSqr = distSqr;
result = foodPiece;
}
}
return result;
}
public void eatFood(Vector2D foodItem)
{
food.remove(foodItem);
}
private void generateFood()
{
}
}