Advertisement
calcpage

C3X9_Bug.java

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