1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| type Dice struct {
top, bottom, left, right, front, back int
}
func (d *Dice) Up() {
d.top, d.bottom, d.left, d.right, d.front, d.back =
d.front, d.back, d.left, d.right, d.bottom, d.top
}
func (d *Dice) Down() {
d.top, d.bottom, d.left, d.right, d.front, d.back =
d.back, d.front, d.left, d.right, d.top, d.bottom
}
func (d *Dice) Left() {
d.top, d.bottom, d.left, d.right, d.front, d.back =
d.right, d.left, d.top, d.bottom, d.front, d.back
}
func (d *Dice) Right() {
d.top, d.bottom, d.left, d.right, d.front, d.back =
d.left, d.right, d.bottom, d.top, d.front, d.back
}
func main() {
dice := Dice{top: 1, bottom: 6, left: 3, right: 4, front: 5, back: 2}
}
|