// CS 101 Assignment 7 -- Lab Problem: HurdleWorld ... // Example of using a global variable. To be AVOIDED! class Hurdler extends Buggle { int n; // n is declared as a global variable (BAD) public int runHurdles() { // run all hurdles and stop at the opposite wall if (atFinishLine()) { // do nothing // should return 0 } else if (isFacingWall()) { jumpHurdle(); n = n+1; // note that n has not been initialized runHurdles(); // note that runHurdles() is not called here as a function } else { forward(); runHurdles(); // runHurdles() is not called here as a function } return n; // n may not have been initialized } ... } // end of class Hurdler