© A+ Computer Science - www.apluscompsci.com ActorWorld world = new ActorWorld(); Bug dude = new Bug(); world.add(new Location(3,3), dude); Bug sally = new Bug(Color.GREEN); sally.setDirection(Location.SOUTHEAST); world.add(new Location(2,2), sally); Bug ali = new Bug(Color.ORANGE); ali.setDirection(Location.NORTHEAST); world.add(new Location(1,1), ali); world.show();
{"Image DocumentName": "\u00a9 A+ Computer Science -", "Image ImageDescription": "Bug. ActorWorld world = new ActorWorld(); Bug dude = new Bug(); world.add(new Location(3,3), dude); Bug sally = new Bug(Color.GREEN); sally.setDirection(Location.SOUTHEAST); world.add(new Location(2,2), sally); Bug ali = new Bug(Color.ORANGE); ali.setDirection(Location.NORTHEAST); world.add(new Location(1,1), ali); world.show(); In this example, a default bug is created. A default bug is red and facing NORTH. The bug moves NORTH until it reaches the top of the grid. The bug them turns in 45 degree increments until it finds an empty location to which to move. Two other bugs are created as well. One of the bugs is green and the other is orange. \u00a9 A+ Computer Science -", "Image XResolution": "37", "Image YResolution": "37", "Image ResolutionUnit": "Pixels/Centimeter", "Image Software": "SlidePlayer", "Image YCbCrPositioning": "Centered"}