Source File: ex15/main.go

package main

import (
    "fmt"
)

// you need this for hitpoints and shared state
var test_global bool = false

func RoomA() string {
    fmt.Println("RoomA")
    return "RoomB"
}

func RoomB() string {
    fmt.Println("RoomB")
    return "End"
}

func End() {
    has_died = true
    fmt.Println("You died.")
}

func main() {
    room := "RoomA"

    for {
        switch room {
        case "RoomA":
            room = RoomA()
        case "RoomB":
            room = RoomB()
        case "End":
            End()
            return
        }
    }
}