<p>@ AK Shockwave: the only things where objects are made into copies when passed into another object are Strings and primitive data types. For example</p>
<p>public void class (){</p>
<p>int x = 9;
int y = 0;
eatMe(x,y);
System.out.println(x + “,” + y);
}</p>
<p>public void eatMe( int m, int n){
m = m +5;
n = n+ 4;
System.out.println(m + “,” + n );}</p>
<p>it would show this:
13,4
9,0</p>
<p>for objects, instead of creatin a whole new copy, what happens is that they just make the variable being passed in point to the object. so</p>
<p>public void class (){</p>
<p>Object x = 9;
Object = 0;
eatMe(x,y);
System.out.println(x + “,” + y);
}</p>
<p>public void eatMe( Object m, Object n){
m = m +5;
n = n+ 4;
System.out.println(m + “,” + n );}</p>
<p>thats not exactly how objects work, but i am not a creative person
what would print would be </p>
<p>13,4
13,4
because the Java points it to the same data reference. Therefore if you change something, the data reference would change as well.</p>
<p>@binatang
Critter gets the actors around it (gets an array of actors in its surrounding) and eats the ones taht are not critters or rocks. then it moves in a random direction</p>
<p>ChameleonCritter gets the actors the same way Critter does but instead of eating them it chooses a random one (math.random()) and changes to its color. Then it moves in a random direction.</p>
<p>Thats why ChameleonCritter overrides Critter’s processActors but not Critter’s getActors. They get actors the same way but what they do with them is different.</p>