Merge pull request #20 from google-developer-training/developer

FiX: Score is not updated for the last word
This commit is contained in:
jtavva 2020-01-16 16:35:46 -08:00 committed by GitHub
commit 3829e9adbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 24 deletions

View File

@ -94,15 +94,11 @@ class GameViewModel : ViewModel() {
/** Methods for updating the UI **/ /** Methods for updating the UI **/
fun onSkip() { fun onSkip() {
if (!wordList.isEmpty()) { _score.value = (_score.value)?.minus(1)
_score.value = (_score.value)?.minus(1)
}
nextWord() nextWord()
} }
fun onCorrect() { fun onCorrect() {
if (!wordList.isEmpty()) { _score.value = (_score.value)?.plus(1)
_score.value = (_score.value)?.plus(1)
}
nextWord() nextWord()
} }

View File

@ -94,15 +94,11 @@ class GameViewModel : ViewModel() {
/** Methods for updating the UI **/ /** Methods for updating the UI **/
fun onSkip() { fun onSkip() {
if (!wordList.isEmpty()) { _score.value = (_score.value)?.minus(1)
_score.value = (_score.value)?.minus(1)
}
nextWord() nextWord()
} }
fun onCorrect() { fun onCorrect() {
if (!wordList.isEmpty()) { _score.value = (_score.value)?.plus(1)
_score.value = (_score.value)?.plus(1)
}
nextWord() nextWord()
} }

View File

@ -138,15 +138,11 @@ class GameViewModel : ViewModel() {
/** Methods for updating the UI **/ /** Methods for updating the UI **/
fun onSkip() { fun onSkip() {
if (!wordList.isEmpty()) { _score.value = (_score.value)?.minus(1)
_score.value = (_score.value)?.minus(1)
}
nextWord() nextWord()
} }
fun onCorrect() { fun onCorrect() {
if (!wordList.isEmpty()) { _score.value = (_score.value)?.plus(1)
_score.value = (_score.value)?.plus(1)
}
nextWord() nextWord()
} }

View File

@ -80,15 +80,11 @@ class GameViewModel : ViewModel() {
/** Methods for updating the UI **/ /** Methods for updating the UI **/
fun onSkip() { fun onSkip() {
if (!wordList.isEmpty()) { score--
score--
}
nextWord() nextWord()
} }
fun onCorrect() { fun onCorrect() {
if (!wordList.isEmpty()) { score++
score++
}
nextWord() nextWord()
} }