Check for existing Turtle object

Listing 5 tests to determine

If so, that means that this is the first time that the button has been clicked

Listing 5. Add a turtle to the world.
          if(turtle == null){
            turtle = new Turtle(150,150,world);
            turtle.setHeading(90);
            turtle.setShellColor(Color.RED);
            turtle.setBodyColor(Color.BLUE);
File: bd.htm [Next] [Prev]