Presentation is loading. Please wait.

Presentation is loading. Please wait.

A closer look at the world

Similar presentations


Presentation on theme: "A closer look at the world"— Presentation transcript:

1 A closer look at the world
Grid World Part 3 A closer look at the world

2 Class interactions

3 Location class (0,0) is top left of grid Constants for direction
(row, column) Constants for direction Location.NORTH Constants for common turn angles Location.LEFT, Location.HALF_RIGHT are and 45

4 Location Methods public Location(int r, int c) public int getRow()
public int getCol() public Location getAdjacentLocation(int direction) public int getDirectionToward(Location target) .equals(Location other) .compareTo(Location other) closest to upper left corner goes first

5 Grid Interface Implemented by BoundedGrid and UnboundedGrid
boolean isValid(Location loc) E put(Location loc, E obj) Put object at location and return previous inhabitant or null E remove(Location loc) E get(Location loc) ArrayList<Location> getOccupiedLocations() int getNumRows() int getNumCols()

6 Grid continued Methods to collect info about surroundings
ArrayList<Location> getValidAdjacentLocations(Location loc) ArrayList<Location> getEmptyAdjacentLocations(Location loc) ArrayList<Location> getOccupiedAdjacentLocations(Location loc) ArrayList<Actor> getNeighbors(Location loc)

7


Download ppt "A closer look at the world"

Similar presentations


Ads by Google