Advertisement
calcpage

GWP2_DancingBug.java

Mar 26th, 2012
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.42 KB | None | 0 0
  1. //DancingBug.java   MrG 2011.1216
  2. import info.gridworld.actor.Bug;
  3. public class DancingBug extends Bug
  4. {
  5.     private int steps;
  6.     private int[] turnList;
  7.  
  8.     public DancingBug(int[] turns)
  9.     {
  10.         steps = 0;
  11.         turnList = turns;
  12.     }
  13.  
  14.     public void turn(int times)
  15.     {
  16.         for(int j=1; j<=times; j++)
  17.         {
  18.             turn();
  19.         }
  20.     }
  21.  
  22.     public void act()
  23.     {
  24.             turn(turnList[steps%turnList.length]);
  25.         steps++;
  26.         super.act();
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement