Created
October 11, 2016 14:25
-
-
Save maxehmookau/235312a538195760d74b0b8d6f598ee8 to your computer and use it in GitHub Desktop.
Little teabot. My first go.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func main() { | |
args := os.Args[1:] | |
name := args[0] | |
fmt.Printf("%s has %d sugars.", name, numberOfSugars(args[0])) | |
if hasMilk(args[0]) { | |
fmt.Printf("%s takes milk too.", name) | |
} | |
if hasDecaff(args[0]) { | |
fmt.Printf("%s only drinks decaff.", name) | |
} | |
} | |
func numberOfSugars(name string) int { | |
switch name { | |
case "Max": | |
return 0 | |
default: | |
return 0 | |
} | |
} | |
func hasMilk(name string) bool { | |
switch name { | |
case "Max": | |
return true | |
default: | |
return false | |
} | |
} | |
func hasDecaff(name string) bool { | |
switch name { | |
case "Max": | |
return false | |
case "Dan": | |
return true | |
default: | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment