Question
public class Tile { private TileType tileType; private Direction orientation; private int tileID; private int position; /** * Constructor for a tile. * * @param
public class Tile {
private TileType tileType;
private Direction orientation;
private int tileID;
private int position;
/** * Constructor for a tile. * * @param tileID The tile ID, a number from 0 ... 8 which encodes which tile * is being constructed. 0..3 are the curve tiles (A, B, C, D). * 4 and 5 are the bridge tiles (E, F), 6 and 7 are the plain * intersection tiles (G, H), and 8 is the CAT tile (I). * @param tileCode The tile code encodes the placement of the tile, encoding * the position and orientation (as described below). *
* The tile code encodes the tile index and tile rotation as follows: *
* tilecode = tilerotation + (4 * tileindex) *
* where tilerotation is a number 0..4 representing orientations * NORTH (0), EAST (1), SOUTH (2), and WEST (3), and tileindex is a * number 0..8 representing which of the nine positions a tile * may be placed in. Tile position 0 corresponds to board position 6, * while tile position 4 corresponds to board position 12. *
* tile index: * 0 1 2 * 3 4 5 * 6 7 8 *
* board positions: * 6 7 8 * 11 12 13 * 16 17 18 */ public Tile(int tileID, int tileCode) { this.tileID = tileID; position = tileCodeToPosition(tileCode); ; orientation = tileCodeToOrientation(tileCode); tileType = TileType.fromTileID(tileID); } /** * Return the set of possible next positions if encountering this tile * from position 'from'. The next positions depend on the shape and * orientation of the tile. For bridge tiles, the orientation does * not matter---the next tile will be the same regardless. For curve * tiles, the orientation will determine which tile is next. For both * curve and bridge tiles, there is only one possible next position. * However, for intersection tiles, there are three possible next positions * (four minus the position 'from'). * * @param from The position from which the path as come. * @return An array of possible next positions. */
public int[] nextPositions(int from) { return tileType.nextPositions(position, from, orientation); }
/** * Given a tile code, decode the tile's rotation, using the description * of tile encoding above. *
* For example, if the tile code is 0, then the function should return NORTH. * If the tile code is 1, then the function should return EAST. If the tile * code is 7, then the function should return WEST etc. * * @param tileCode The encoded tile rotation and position * @return the corresponding direction of rotation (where NORTH is upright). */
static Direction tileCodeToOrientation(int tileCode) { return null);
Is there someone could give me an answer and tell me why?
Thanks!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started