Analysis Questions Set 1 1. It gets the information from the environment. 2. SimpleMBSDemo2 has the step method do everything for it, while SimpleMBSDemo1 does it all itself. Exercise Set 1 1. public static void main(String[] args) { BoundedEnv env = new BoundedEnv(ENV_ROWS, ENV_COLS); Location loc1 = new Location(7, 3); Location loc2 = new Location(7, 4); Direction dir1 = env.getDirection(loc1, loc2); Direction dir2 = dir1.toRight(90); Direction dir3 = dir2.reverse(); Location loc3 = env.getNeighbor(loc1, dir3); Location loc4 = env.getNeighbor(new Location(5, 2), dir1); 2. North = 0, East = 90, South = 180, East = 270 Analysis Question Set 2 1. (6, 3) (7, 4) (8, 3) (7, 2) 2. East 3. South, North 4. (6, 3) 5. (5, 3) Exercise Set 2 1. public static void main(String[] args) { BoundedEnv env = new BoundedEnv(ENV_ROWS, ENV_COLS); Location loc1 = new Location(7,3); Location loc2 = new Location(2,6); Location loc3 = new Location(4,7); Fish f1 = new Fish(env, loc1); Fish f2 = new Fish(env, loc2); 2. Fish f3 = new Fish(env, loc3); env.numObjects(); f3.remove(); env.numObjects(); 3. env.add(Fish f1); Analysis Question Set 3 1. 2 2. 5. 3. false 4. true 5. f2 6. null 7. yes Analysis Question Set 4 1. It starts in the consistent state. 2. If it is removed, then it becomes inconsistent. Analysis Question Set 5 1. true, true 2. false, false 3. false, true Analysis Question Set 6 1. Because neighborsOf returns ALL the neighbors. Exercise Set 3 1. (0, 0) - 2 (0, 1) - 3 (1, 1) - 4 Arraylist ar1 = env.neighborsOf(loc1); Arraylist ar2 = env.neighborsOf(loc2); Arraylist ar3 = env.neighborsOf(loc3); 2. (1, 0) (0, 0) (1, 0) 3. Depends on the size of the environment. Analysis Question Set 8 1. 2. Exercise Set 4 1.