Ellen Spertus
11/06/2022, 9:53 PMclass WordleGame(val secretWord: String) {
// lots of stuff in here pertaining to a single game of Wordle.
val guesses = mutableListOf<String>()
fun guessWord(guess: String): String {
...
}
}
fun playGame() {
// Load dictionary.
val wordleGame = WordleGame(dictionary.random())
// Solicit guesses from user and feed them to game object, etc.
}
Should playGame()
be in a companion object
in WordleGame
? It certainly would be a handy place to keep the dictionary.Chris Fillmore
11/07/2022, 1:36 AMcompanion object
. That’s been my experience anyway.