Skip to content

Instantly share code, notes, and snippets.

@xstrengthofonex
Created March 11, 2018 06:53
Show Gist options
  • Save xstrengthofonex/63ef83d75509049d326cddcbcbeaaf36 to your computer and use it in GitHub Desktop.
Save xstrengthofonex/63ef83d75509049d326cddcbcbeaaf36 to your computer and use it in GitHub Desktop.
private String assembleDirections() {
available = new StringBuffer();
nDirections = directions.size();
directionsPlaced = 0;
for (String dir: new String[]{Game.NORTH, Game.SOUTH, Game.EAST, Game.WEST}) {
if (direction.contains(dir)) {
placeDirection(dir);
}
}
}
private void placeDirection(String dir) {
directionsPlaced++;
if (isLastOfMany()) {
available.append(" and ");
} else if (notFirst()) {
available.append(", ");
}
available.append(directionName(dir));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment