-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (42 loc) · 834 Bytes
/
main.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"os"
)
func main() {
var guess string
dict := getDict()
answer := dict.randomWordOfDay()
guesses := guessList{}
totalGuessLeft := 6
presentation()
for totalGuessLeft > 0 {
fmt.Print("Guess: ")
fmt.Scanln(&guess)
msg, err := validateGuess(dict, guess, guesses)
if err != nil {
fmt.Println(msg)
} else {
checkedGuess, guessed := checkGuess(answer, guess)
if guessed {
win(answer)
os.Exit(0)
}
guesses = append(guesses, checkedGuess)
guesses.printPastGuesses()
totalGuessLeft--
}
}
lost(answer)
}
func presentation() {
fmt.Println("Welcome to Gordle!")
fmt.Println("Try to guess the 5 letter word of the day: ")
}
func win(g string) {
fmt.Println(g, "was the answer!")
fmt.Println("Good job!")
}
func lost(a string) {
fmt.Println("You lost.")
}