From 7d4fea5a66a3534b95a18d0e68da8b9835fbf343 Mon Sep 17 00:00:00 2001 From: I Gede Depri Pramana <46771648+DepriPramana@users.noreply.github.com> Date: Fri, 16 Oct 2020 16:35:56 +0800 Subject: [PATCH] correction scoreKeeper when finish Before add _maxQuestion the last answer not write in scoreKeeper we don't know the last asnwer true or false. so i add this for see last asnwer on scoreKeeper --- lib/quiz_brain.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/quiz_brain.dart b/lib/quiz_brain.dart index 68e1339..c96403b 100644 --- a/lib/quiz_brain.dart +++ b/lib/quiz_brain.dart @@ -2,6 +2,7 @@ import 'question.dart'; class QuizBrain { int _questionNumber = 0; + int _maxQuestion = 0; List _questionBank = [ Question('Some cats are actually allergic to humans', true), @@ -48,13 +49,14 @@ class QuizBrain { //TODO: Step 3 Part A - Create a method called isFinished() here that checks to see if we have reached the last question. It should return (have an output) true if we've reached the last question and it should return false if we're not there yet. bool isFinished() { - if (_questionNumber >= _questionBank.length - 1) { + if (_maxQuestion >= _questionBank.length) { //TODO: Step 3 Part B - Use a print statement to check that isFinished is returning true when you are indeed at the end of the quiz and when a restart should happen. print('Now returning true'); return true; } else { + _maxQuestion++; return false; } }