import becker.robots.*; /** * This class is to be used (without modification) as a driver for the exercise based loosely on Programming Project * 3.13 on page 164. The full description can be found here. *
Date:
2008 05 05
* @author C. D'Arcy
* @version 1.0
*/
public class Castles {
public static void main (String [] args) {
// Define the canvas
Shire nottingham = new Shire("Castles.txt");
// Instantiate the objects that patrol King Java's Castle
ShortWallGuard swg0 = new ShortWallGuard(nottingham, 0, 0, Direction.EAST,"John");
ShortWallGuard swg1 = new ShortWallGuard(nottingham, 0, 5, Direction.SOUTH,"Paul");
ShortWallGuard swg2 = new ShortWallGuard(nottingham, 5, 5, Direction.WEST,"George");
ShortWallGuard swg3 = new ShortWallGuard(nottingham, 5, 0, Direction.NORTH,"Ringo");
// Instantiate the objects that patrol King Caffeine's Castle
LongWallGuard lwg0 = new LongWallGuard(nottingham, 0, 6, Direction.EAST,"Curly");
LongWallGuard lwg1 = new LongWallGuard(nottingham, 0, 12, Direction.SOUTH,"Larry");
LongWallGuard lwg2 = new LongWallGuard(nottingham, 6, 12, Direction.WEST,"Moe");
LongWallGuard lwg3 = new LongWallGuard(nottingham, 6, 6, Direction.NORTH,"Shemp");
// Attach each guard to his own separate thread
Thread thread0 = new Thread(swg0);
Thread thread1 = new Thread(swg1);
Thread thread2 = new Thread(swg2);
Thread thread3 = new Thread(swg3);
Thread thread4 = new Thread(lwg0);
Thread thread5 = new Thread(lwg1);
Thread thread6 = new Thread(lwg2);
Thread thread7 = new Thread(lwg3);
// Launch the threads
thread0.start();
thread1.start();
thread2.start();
thread3.start();
thread4.start();
thread5.start();
thread6.start();
thread7.start();
}
}