subject

Currently, a fox will eat at most one rabbit at each step. Modify the findFood method so that rabbits in all adjacent locations are eaten at a single step. Asssess the impact of this change on the results of the simulation. Note that findFood method currently returns the location of the single rabbit that is eaten, so you will need to return the location of the one of the eaten rabbits in your version. However, don’t forget to return null if there are no rabbits to eat.
Original Code
01
private Location findFood()
02
{
03
List adjacent = field. adjacentLocations(location);
04
Iterator it = adjacent. iterator();
05
while(it. hasNext()) {
06
Location where = it. next();
07
Object animal = field. getObjectAt(where);
08
if(animal instanceof Rabbit) {
09
Rabbit rabbit = (Rabbit) animal;
10
if(rabbit. isAlive()) {
11
rabbit. setDead();
12
foodLevel = RABBIT_FOOD_VALUE;
13
return where;
14
}
15
}
16
}
17
return null;
18
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:40
Write a function 'music_func' that takes 3 parameters -- music type, music group, vocalist -- and prints them all out as shown in the example below. in case no input is provided by the user, the function should assume these values for the parameters: "classic rock", "the beatles", "freddie mercury". for example: input: alternative rock,pearl jam,chris cornell output: the best kind of music is alternative rock the best music group is pearl jam the best lead vocalist is chris cornell note: the print statements will go inside the for example: print("the best kind of music is"
Answers: 2
question
Computers and Technology, 23.06.2019 00:20
The open systems interconnection (osi) reference model: defines standards for many aspects of computing and communications within a network. is a generic description for how computers use multiple layers of protocol rules to communicate across a network. defines standards for wireless local area network (wlan) communication protocols. details the advantages and disadvantages of various basic network cabling options.
Answers: 1
question
Computers and Technology, 23.06.2019 03:10
Acomputer has a two-level cache. suppose that 60% of the memory references hit on the first level cache, 35% hit on the second level, and 5% miss. the access times are 5 nsec, 15 nsec, and 60 nsec, respectively, where the times for the level 2 cache and memory start counting at the moment it is known that they are needed (e.g., a level 2 cache access does not even start until the level 1 cache miss occurs). what is the average access time?
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
Which statistical function in a spreadsheet you to see how far each number varies, on average, from the average value of the list?
Answers: 2
You know the right answer?
Currently, a fox will eat at most one rabbit at each step. Modify the findFood method so that rabbit...
Questions