added count Votes to playground

This commit is contained in:
John O'Keefe 2023-12-19 09:24:56 -05:00
parent b2579520b9
commit 276d8b42d3
2 changed files with 22 additions and 0 deletions

19
playground/countVotes.go Normal file
View File

@ -0,0 +1,19 @@
// from Chapter 7 of Head First Go
package main
import (
"fmt"
"git.linuxhg.com/john-okeefe/datafile"
"git.linuxhg.com/john-okeefe/keyboard"
"strings"
)
func countVotes() {
fmt.Printf("What is the name of the file: ")
fileString, err := keyboard.GetString()
Error(err)
fileString = strings.TrimSpace(fileString)
lines, err := datafile.GetStrings(fileString)
Error(err)
fmt.Println(lines)
}

View File

@ -38,6 +38,8 @@ func main() {
slices()
case "Variadic Functions":
variadic()
case "Count Votes":
countVotes()
}
return nil
})
@ -55,6 +57,7 @@ func main() {
menu.Option("Get the Average Variadic", nil, false, nil)
menu.Option("Slices", nil, false, nil)
menu.Option("Variadic Functions", nil, false, nil)
menu.Option("Count Votes", nil, false, nil)
err := menu.Run()
if err != nil {
log.Fatal(err)