Advertisement
calcpage

APCS2012_C3X9_Bug.java

Oct 10th, 2012
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.30 KB | None | 0 0
  1. //Bug.java      MrG     2012.1009
  2. public class Bug
  3. {
  4.     private int dir;
  5.     private int pos;
  6.  
  7.     public Bug(int pos)
  8.     {
  9.         this.pos=pos;
  10.         dir=1;
  11.     }
  12.  
  13.     public int getPosition()
  14.     {
  15.         return pos;
  16.     }
  17.  
  18.     public void move()
  19.     {
  20.         pos+=dir;
  21.     }
  22.  
  23.     public void turn()
  24.     {
  25.         dir*=-1;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement