Question: Java problem.Here is an enum. public enum Direction { NORTH , EAST , SOUTH , WEST ;} And then I need to return direction. /**

Java problem.Here is an enum. public enum Direction { NORTH, EAST, SOUTH, WEST;} 

And then I need to return direction.

/**  * 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); }

 /**  * 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 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!