To load this file without formatting, visit http://whoyouknow.co.uk/ants/AntGraph/java/3/src/antgraph/Ant.java. This is a spam-protection measure; sorry for the inconvenience.
· Ant.java ·
1/* 2 * Ant.java 3 * 4 * Created on 04 March 2007, 01:34 5 * 6 * To change this template, choose Tools | Template Manager 7 * and open the template in the editor. 8 */ 9 10package antgraph; 11 12/** 13 * 14 * @author James 15 */ 16public class Ant implements Runnable { 17 18 private Food food = null; 19 private Thread move; 20 private Node node = null; 21 22 private static int sleepRate = 5000; 23 24 /** Creates a new instance of Ant */ 25 public Ant(Node node) { 26 this.node = node; 27 } 28 29 public boolean carryingFood() { 30 return food != null; 31 } 32 33 public Food getFood() { 34 return food; 35 } 36 37 public void setFood(Food food) { 38 this.food = food; 39 } 40 41 public void move() { 42 43 //move! 44 45 } 46 47 public void run() { 48 49 while(move != null) { 50 try { 51 move(); 52 53 move.sleep(getSleepRate()); 54 }catch (InterruptedException e) {} 55 } 56 } 57 58 public void start() { 59 //Create and start a new Thread. 60 move = new Thread(this); 61 move.setDaemon(true); 62 move.start(); 63 } 64 65 public void pause() { 66 if(move == null) start(); 67 else stop(); 68 } 69 70 71 public void stop() { 72 move = null; 73 } 74 75 public static int getSleepRate() { 76 return sleepRate; 77 } 78 79 public static void setSleepRate(int aSleepRate) { 80 sleepRate = aSleepRate; 81 } 82} 83
· Ant.java ends ·
To load this file without formatting, visit http://whoyouknow.co.uk/ants/AntGraph/java/3/src/antgraph/Ant.java. This is a spam-protection measure; sorry for the inconvenience.