// Bug.m #import "Bug.h" #import <random.h> @implementation Bug - setX: (int)x Y: (int)y { xPos = x; yPos = y; printf("I started at X = %d Y = %d \n\n", xPos,yPos); return self; } - setWorldSizeX: (int)xSize Y:(int)ySize
{ worldXSize = xSize; worldYSize = ySize; 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; return self; } @end