// Bug.m #import "Bug.h" @implementation Bug -setWorldSizeX: (int) xSize: (int) ySize { worldSize = xSize; worldSize = ySize; return self; } -setFoodSpace: (id) f { foodSpace = f; return self; } -createEnd { return [super createEnd]; } -setX: (int) x Y: (int) y { xPos = x; yPos = y; return self; } -step { xPos = xPos + [uniformIntRand getIntegerWithMin: -1 WithMax: 1]; yPos = yPos + [uniformIntRand getIntegerWithMin: -1 WithMax: 1]; xPos = (xPos + worldSize) % worldSize; yPos = (yPos + worldSize) % worldSize; if([foodSpace getValueAtX: xPos Y:yPos] == 1) { [foodSpace putValue: 0 atX: xPos Y:yPos]; } return self; } @end