package main
import (
"fmt"
"strings"
"time"
)
func main(){
fmt.Println("You find yourself in a dimly lit cavern.")
var command = "walk outside"
var exit = strings.Contains(command, "outside")
fmt.Println("You leave the cave:", exit)
fmt.Println("There is a sign near the entrance that reads 'No Minors'.")
var age = 41
var minor = age < 18
fmt.Printf("At age %v, am I a minor? %v\n", age, minor)
var commands = "go east"
if commands == "go east"{
fmt.Println("You head further up the mountain.")
} else if commands == "go inside" {
fmt.Println("You enter the cave where you live out the rest of your life.")
} else {
fmt.Println("Didn't quite get that.")
}
fmt.Println("The year is 2020, should you leap?")
var year = 2020
var leap = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)
if leap {
fmt.Println("Look before you leap!")
} else {
fmt.Println("Keep your feet on the ground.")
}
var haveTorch = true
var litTorch = false
if !haveTorch || !litTorch {
fmt.Println("Nothing to see here.")
}
fmt.Println("There is a cavern entrance here and a path to the east.")
var commandss = "go inside"
switch commandss {
case "go east":
fmt.Println("You head further up the moutain.")
case "enter cave", "go inside":
fmt.Println("You find yourself in a dimly lit cavern.")
case "read sign":
fmt.Println("The sign reads 'No Minors'.")
default:
fmt.Println("Didn't quite get that.")
}
var room = "lake"
switch {
case room == "cave":
fmt.Println("You find yourself in a dimly lit cavern.")
case room == "lake":
fmt.Println("The ice seems solid enough.")
fallthrough
case room == "underwater":
fmt.Println("The water is freezing cold.")
}
var count = 10
for count > 0 {
fmt.Println(count)
time.Sleep(time.Second * 2)
count--
}
fmt.Println("Liftoff!")
}
转载请注明原文地址:https://blackberry.8miu.com/read-44943.html