A little cleaner implementation

This commit is contained in:
John Long
2022-01-03 16:45:26 -08:00
parent 1e9c8008d1
commit 8be28cd39a

View File

@@ -13,8 +13,13 @@
fun main() {
println(introText)
synonyms.forEach {
// Inside with, "this" is the current synonym
with(it) {
it.testUser()
}
println("SYNONYM DRILL COMPLETED.")
}
// We could put this inside of SynonymList, but this keeps the core implementation
// right here at the top
private fun SynonymList.testUser() {
do {
val answer = ask(" WHAT IS A SYNONYM OF $word ? ")
when {
@@ -27,9 +32,6 @@ fun main() {
}
} while (!synonyms.contains(answer))
}
}
println("SYNONYM DRILL COMPLETED.")
}
val introText = """
${tab(33)}SYNONYM