-
Notifications
You must be signed in to change notification settings - Fork 9
/
Direction.java
42 lines (34 loc) · 1.2 KB
/
Direction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//------------------------------------------------------------------//
// Direction.java //
// //
// Enumeration Type used to represent a Movement Direction //
// Each Direction object includes the vector of Direction //
// //
// Author: W16-CSE8B-TA group //
// Date: 1/17/16 //
//------------------------------------------------------------------//
/**
* DO NOT MODIFY THIS FILE
*/
public enum Direction {
// The Definitions for UP, DOWN, LEFT, and RIGHT
UP(0, -1), DOWN(0, 1), LEFT(-1, 0), RIGHT(1, 0);
private final int y;
private final int x;
Direction(int x, int y) {
this.x = x;
this.y = y;
}
// Retrieve the X component of direction
public int getX() {
return x;
}
// Retrieve the Y component of direction
public int getY() {
return y;
}
@Override
public String toString() {
return name() + "(" + x + ", " + y + ")";
}
}