====== More on Methods in Robocode ====== ---- See [[https://piazza.com/class_profile/get_resource/hzkswvpxv2r2nu/i1zch0mkzjn32d|a version of the CenterBot]] from Assignment 4. This version uses [[list_of_cs-175_assignments#centerbot1|Approach #3]] to get to the center of the battlefield. * A. In //CenterBot4.java//, define the //public void gotoCenter// method, and call it from the Robot main loop to get to the center. Use the [[robocode_lab_-_nearestwallbot1|NearestWallBot1]] as an example of defining a method and calling it. * B. Write a generalized variation of the //gotoCenter// method called //gotoCoords// that allows the robot to go to any x,y coordinates. It would be used like this from the Robot main loop, // x=0, y=0; moves to lower left corner gotoCoords( 0, 0 ); // x=800, y=600; moves to upper right corner gotoCoords( 800, 600 ); [[https://piazza.com/class_profile/get_resource/hzkswvpxv2r2nu/i33jms8rsc71g5|Link to CenterBot4.java]] ----