-
Notifications
You must be signed in to change notification settings - Fork 0
/
direction.go
49 lines (41 loc) · 933 Bytes
/
direction.go
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
43
44
45
46
47
48
49
package main
const (
// EAST direction
EAST string = "EAST"
// WEST direction
WEST string = "WEST"
// NORTH direction
NORTH string = "NORTH"
// SOUTH direction
SOUTH string = "SOUTH"
)
// Direction stores name of current direction and its inverse direction
type Direction struct {
name string
inverse *Direction
}
// InitDirections creates a map containing all supported directions
func InitDirections() map[string]Direction {
eastDirection := Direction{
name: EAST,
}
westDirection := Direction{
name: WEST,
}
northDirection := Direction{
name: NORTH,
}
southDirection := Direction{
name: SOUTH,
}
eastDirection.inverse = &westDirection
westDirection.inverse = &eastDirection
northDirection.inverse = &southDirection
southDirection.inverse = &northDirection
return map[string]Direction{
EAST: eastDirection,
WEST: westDirection,
NORTH: northDirection,
SOUTH: southDirection,
}
}