-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (31 loc) · 788 Bytes
/
main.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
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
fmt.Println("Switch case")
fmt.Println("Rolling a dice...")
source := rand.NewSource(time.Now().UnixNano())
generator := rand.New(source)
diceResult := generator.Intn(6) + 1
fmt.Println("The dice was rolled and the result is:", diceResult)
switch diceResult {
case 1:
fmt.Println("You got 1 and can open")
case 2:
fmt.Println("You can move 2 places")
case 3:
fmt.Println("You can move 3 places")
case 4:
fmt.Println("You can move 4 places")
case 5:
fmt.Println("You can move 5 places")
// fallthrough // can optionally specific fallthrough if want to go through all remaining cases
case 6:
fmt.Println("You can move 6 places and roll again")
default:
fmt.Println("WTH happened!")
}
}