AbstractRobot |
1 package interfaces; 2 3 /** 4 * Interface class for both real and simulated robots. 5 * Defines all the input and output methods a controller 6 * can call. 7 * 8 * @author Graham Ritchie 9 */ 10 public interface AbstractRobot 11 { 12 /****************************************** 13 Methods for moving the robot - output 14 ******************************************/ 15 16 /** 17 * Sets the robot moving forwards, this will continue until some other 18 * method is called to stop it. 19 */ 20 public abstract void forward(); 21 22 /** 23 * Makes the robot move forwards for the given amount of time 24 * 25 * @param time the time in milliseconds 26 */ 27 public abstract void forward(int time); 28 29 /** 30 * Sets the robot moving backwards, this will continue until some other 31 * method is called to stop it. 32 */ 33 public abstract void backward(); 34 35 /** 36 * Makes the robot move backwards for the given amount of time 37 * 38 * @param time the time in milliseconds 39 */ 40 public abstract void backward(int time); 41 42 /** 43 * Sets the robot spinning right, this will continue until some other 44 * method is called to stop it. 45 */ 46 public abstract void right(); 47 48 /** 49 * Spins the robot right for the given amount of time 50 * 51 * @param time the time in milliseconds 52 */ 53 public abstract void right(int time); 54 55 /** 56 * Sets the robot spinning left, this will continue until some other 57 * method is called to stop it. 58 */ 59 public abstract void left(); 60 61 /** 62 * Spins the robot left for the given amount of time 63 * 64 * @param time the time in milliseconds 65 */ 66 public abstract void left(int time); 67 68 /** 69 * Stops all motors immediately 70 */ 71 public abstract void stopMoving(); 72 73 74 /** 75 * Makes the robot beep 76 */ 77 public abstract void beep(); 78 79 80 /************************************************* 81 Methods for reading the robot's sensors - input 82 **************************************************/ 83 84 /** 85 * Get the current reading of this sensor 86 * 87 * @return the current value 88 */ 89 public abstract int getSensor1(); 90 91 /** 92 * Get the current reading of this sensor 93 * 94 * @return the current value 95 */ 96 public abstract int getSensor2(); 97 98 /** 99 * Get the current reading of this sensor 100 * 101 * @return the current value 102 */ 103 public abstract int getSensor3(); 104 } 105
AbstractRobot |