Hi I have a robot which I need to tell it to move a certain number of times forward by saying forward 5. I have the method, I just need to get it to work in my class. Here is the method:
public void moveNumOfTimes(int num)
{
//-----------------------------------------------------------------------------------------------
int i=0;
while(i<num) {
if (this.frontIsClear()){ // if the front is NOT clear the robot should not move, otherwise will collide into the wall
this.move();
}
i++; // same as i=i+1;
}
//-----------------------------------------------------------------------------------------------
}
How do I enter that in my program? Is it like this?
moveNumOfTimes(int num);
Hope someone can help. Thanks