Average Density: 0.03
 1 package nl.tudelft.jpacman.board;
 2 
 3 /**
 4  * An enumeration of possible directions on a two-dimensional square grid.
 5  *
 6  * @author Jeroen Roosen 
 7  */
 8 public enum Direction {
 9 
10     /**
11      * North, or up.
12      */
13     NORTH(0, -1),
14 
15     /**
16      * South, or down.
17      */
18     SOUTH(0, 1),
19 
20     /**
21      * West, or left.
22      */
23     WEST(-1, 0),
24 
25     /**
26      * East, or right.
27      */
28     EAST(1, 0);
29 
30     /**
31      * The delta x (width difference) to an element in the direction in a grid
32      * with 0,0 (x,y) as its top-left element.
33      */
34     private final int deltaX;
35 
36     /**
37      * The delta y (height difference) to an element in the direction in a grid
38      * with 0,0 (x,y) as its top-left element.
39      */
40     private final int deltaY;
41 
42     /**
43      * Creates a new Direction with the given parameters.
44      *
45      * @param deltaX
46      *            The delta x (width difference) to an element in the direction
47      *            in a matrix with 0,0 (x,y) as its top-left element.
48      * @param deltaY
49      *            The delta y (height difference) to an element in the direction
50      *            in a matrix with 0,0 (x,y) as its top-left element.
51      */
52     Direction(int deltaX, int deltaY) {
53         this.deltaX = deltaX;
54         this.deltaY = deltaY;
55     }
56 
57     /**
58      * @return The delta x (width difference) for a single step in this
59      *         direction, in a matrix with 0,0 (x,y) as its top-left element.
60      */
61     public int getDeltaX() {
62         return deltaX;
63     }
64 
65     /**
66      * @return The delta y (height difference) for a single step in this
67      *         direction, in a matrix with 0,0 (x,y) as its top-left element.
68      */
69     public int getDeltaY() {
70         return deltaY;
71     }
72 }