Advertisement
IvonLiu

Untitled

Mar 8th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. // BEGIN CHANGED
  2. private int c;
  3.  
  4. public BlusterCritter(int c) {
  5.   this.c = c;
  6. }
  7. // END CHANGED
  8.  
  9. @Override
  10. public ArrayList<Actor> getActors() {
  11.  
  12.   int minRow = Math.max(getLocation().getRow() - 2, 0);
  13.   int maxRow = Math.min(getLocation().getRow() + 2, getGrid().getNumRows());
  14.  
  15.   int minCol = Math.max(getLocation().getCol() - 2, 0);
  16.   int maxCol = Math.min(getLocation().getCol() + 2, getGrid().getNumCols());
  17.  
  18.   ArrayList<Actor> actors = new ArrayList<>();
  19.  
  20.   for (int row=minRow; row<maxRow; row++) {
  21.     for (int col=minCol; col<maxCol; col++) {
  22.       Actor actor = getGrid().get(new Location(row, col));
  23.       if (actor != null && actor instanceof Critter) {      // CHANGED
  24.         actors.add(actor);
  25.       }
  26.     }
  27.   }
  28.  
  29.   return actors;
  30. }
  31.  
  32. @Override
  33. public void processActors(ArrayList<Actor> actors) {
  34.  
  35.   if (actors.size() < c) {
  36.     // Get lighter
  37.   } else {
  38.     // Get darker
  39.   }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement