summaryrefslogtreecommitdiff
path: root/go/bob/bob.go
blob: 129c0aa5041f6c556331fa8151c3a15e10d6eacb (plain)
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
package bob

import (
	"strings"
	"unicode"
)

const testVersion = 2

func Hey(s string) string {
	s = strings.TrimSpace(s)
	var hasUpper bool
	var hasLower bool
	for _, r := range s {
		switch {
		case unicode.IsUpper(r):
			hasUpper = true
		case unicode.IsLower(r):
			hasLower = true
		}
	}
	switch {
	case hasUpper && !hasLower:
		return "Whoa, chill out!"
	case strings.HasSuffix(s, "?"):
		return "Sure."
	case len(s) == 0:
		return "Fine. Be that way!"
	default:
		return "Whatever."
	}
}