aznishboy

circleBug

Jan 12th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.64 KB | None | 0 0
  1. import info.gridworld.actor.*;
  2. import info.gridworld.grid.*;
  3.  
  4. public class circleBug extends Bug{
  5.    
  6.     private int steps;
  7.     private int sideLength;
  8.  
  9.     /**
  10.      * Constructs a box bug that traces a square of a given side length
  11.      * @param length the side length
  12.      */
  13.     public circleBug(int length)
  14.     {
  15.         steps = 0;
  16.         sideLength = length;
  17.     }
  18.  
  19.     /**
  20.      * Moves to the next location of the square.
  21.      */
  22.     public void act()
  23.     {
  24.         if (steps < sideLength && canMove())
  25.         {
  26.             move();
  27.             steps++;
  28.         }
  29.         else
  30.         {
  31.             turn();
  32.             steps = 0;
  33.         }
  34.     }  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment