All language subtitles for 14. Adding Back the Score Keeper

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 0 1 00:00:00,420 --> 00:00:08,340 So now that we've got the majority of our functionality down, it's finally time to put back our icons 1 2 00:00:08,400 --> 00:00:11,650 at the bottom to be at the track the user's score. 2 3 00:00:11,670 --> 00:00:17,760 So the part where we're actually figuring out if the user got the question right or wrong is right here. 3 4 00:00:18,360 --> 00:00:22,270 And you can see that at the moment, it's repeated in two places 4 5 00:00:22,320 --> 00:00:22,860 right? 5 6 00:00:22,920 --> 00:00:26,130 When the user picks false and also when the user picks 6 7 00:00:26,250 --> 00:00:26,760 true. 7 8 00:00:27,030 --> 00:00:32,200 So let's consolidate all of that code together into a single function. 8 9 00:00:32,250 --> 00:00:38,700 So we'll do it right up here just below where we have our scorekeeper. And we're going to call that method 9 10 00:00:38,790 --> 00:00:40,260 because we're inside a class. 10 11 00:00:40,290 --> 00:00:45,630 So this is going to be a method that's associated with the class. And this method is gonna be called 11 12 00:00:45,690 --> 00:00:53,940 checkAnswer. And checkAnswer is going to take a single input and the parameter is going to be a boolean 12 13 00:00:53,940 --> 00:01:02,160 type that's going to be called userPickedAnswer. And then inside the parentheses, we're going to actually 13 14 00:01:02,160 --> 00:01:03,900 go about checking the answer. 14 15 00:01:03,960 --> 00:01:07,640 So we'll need to transplant some of this functionality over. 15 16 00:01:07,770 --> 00:01:16,890 So I'm gonna go ahead and take all of this and take it out of here and put it into checkAnswer. 16 17 00:01:17,070 --> 00:01:25,530 So essentially, when we call checkAnswer, we're gonna pass in the picked answer and then we can check to 17 18 00:01:25,530 --> 00:01:27,990 see if it's the same as the correct answer. 18 19 00:01:28,080 --> 00:01:34,740 So instead of checking if correct answer equals true, we're going to be checking if userPickedAnswer 19 20 00:01:35,250 --> 00:01:36,440 is equals 20 21 00:01:36,480 --> 00:01:40,380 ,so double equals, to correctAnswer. 21 22 00:01:40,380 --> 00:01:43,500 And remember that a single equals sign is assignment. 22 23 00:01:43,500 --> 00:01:50,640 So left hand side should now equal right hand side and a double equal sign is a check for equality. 23 24 00:01:50,700 --> 00:01:55,880 So we're checking to see if the left hand side is equal to the right hand side. 24 25 00:01:56,010 --> 00:01:59,700 And if it's true, then print user got it right 25 26 00:01:59,700 --> 00:02:01,710 else print user got it wrong. 26 27 00:02:01,710 --> 00:02:09,540 So now down here when the user actually presses the true button, we're simply going to call that method 27 28 00:02:09,840 --> 00:02:10,890 checkAnswer and 28 29 00:02:10,920 --> 00:02:17,970 we're going to pass in the userPickedAnswer which is true in this case. But down here, instead of all 29 30 00:02:17,970 --> 00:02:25,530 of this code, we can actually simply just call checkAnswer again, and we're going to pass in false. 30 31 00:02:25,530 --> 00:02:32,250 So now we should have exactly the same functionality as before but we've just moved it out into a separate 31 32 00:02:32,250 --> 00:02:33,240 method. 32 33 00:02:33,330 --> 00:02:41,070 So if you want to test it again, let's hit save and just click run and we should still be getting the 33 34 00:02:41,130 --> 00:02:45,450 right answers or the wrong answers into our console. 34 35 00:02:45,690 --> 00:02:54,000 Now instead of getting these print statements, we want to be able to add our icons into our scorekeeper 35 36 00:02:54,420 --> 00:03:02,880 which we know is being rendered onscreen at the bottom, as a row. And as we have more icons as children 36 37 00:03:02,880 --> 00:03:07,020 of this row, they should build up along the very bottom. 37 38 00:03:07,020 --> 00:03:14,280 So as a challenge, can you figure out how to, instead of having these print statements, have our little 38 39 00:03:14,280 --> 00:03:22,800 ticks and crosses show up to track the user's score? Pause the video and try to complete the challenge. 39 40 00:03:23,050 --> 00:03:23,360 All right. 40 41 00:03:23,390 --> 00:03:26,750 So we know that we have this list called scorekeeper. 41 42 00:03:26,750 --> 00:03:29,470 And at the moment it's completely empty. 42 43 00:03:29,480 --> 00:03:39,470 We know that we can add to the list by simply just adding an icon which is a check icon or a close icon. 43 44 00:03:40,360 --> 00:03:48,500 And we can also give the icon style such as a color or size etc. But we don't really want to do it here. 44 45 00:03:48,500 --> 00:03:51,820 We want to do it when the user actually gets it right or wrong, 45 46 00:03:51,830 --> 00:03:55,380 so inside these IF and ELSE statements. 46 47 00:03:55,460 --> 00:04:01,520 So if the user got it right, instead of printing it, we're going to add to our scorekeeper. 47 48 00:04:01,530 --> 00:04:09,860 So we're going to say scorekeeper.add. And the icon that we're going to add in there is going to be 48 49 00:04:10,130 --> 00:04:11,890 a check icon, 49 50 00:04:11,930 --> 00:04:13,870 so icons.check. 50 51 00:04:15,200 --> 00:04:25,140 And it's also going to have a color property, and the color is going to be colors.green. And then 51 52 00:04:25,170 --> 00:04:27,630 we've got our ELSE. 52 53 00:04:27,630 --> 00:04:35,340 So when the user gets it wrong, then scorekeeper is going to get a new icon and that icon is going to 53 54 00:04:35,340 --> 00:04:38,190 be the close icon. 54 55 00:04:38,190 --> 00:04:49,320 So icons.close. And this icon is going to have a color property of red. We have to make sure I spell 55 56 00:04:49,320 --> 00:04:53,440 it the American way, colors.red. 56 57 00:04:53,560 --> 00:04:54,150 Okay. 57 58 00:04:54,270 --> 00:05:02,430 So now all we have to do is to include all of this stuff which we know updates something that's being 58 59 00:05:02,430 --> 00:05:11,550 displayed onscreen inside our set state, so that when the scorekeeper list gets updated, our app knows 59 60 00:05:11,610 --> 00:05:18,150 to update the row over here and show up new icons as they get added. 60 61 00:05:18,180 --> 00:05:24,840 All I'm going to do is just to cut this first line of set state and I'm going to put it right up here just 61 62 00:05:24,840 --> 00:05:28,870 before IF statement where we change our scorekeeper list. 62 63 00:05:29,250 --> 00:05:36,780 So now inside our set state, you can see that includes changing the scorekeeper and also calling quiz 63 64 00:05:36,780 --> 00:05:44,020 Brain.nextQuestion which we know is going to bring us the next question in the question bank 64 65 00:05:44,220 --> 00:05:47,960 and it will put it into our text widget 65 66 00:05:47,990 --> 00:05:50,290 here. 66 67 00:05:50,430 --> 00:05:55,020 So now let's hit save and hot reload and test it out. 67 68 00:05:55,080 --> 00:05:58,310 So some cats are actually allergic to humans. 68 69 00:05:58,350 --> 00:05:59,570 It's true. 69 70 00:05:59,880 --> 00:06:02,410 You can lead a cow downstairs but not upstairs. 70 71 00:06:02,820 --> 00:06:05,040 Maybe it's false. 71 72 00:06:05,040 --> 00:06:13,080 And as you go through this list of questions, you can see that we get our progress indicated 72 73 00:06:13,230 --> 00:06:17,840 and it also keeps track of which question we got wrong and which ones we got right. 73 74 00:06:17,850 --> 00:06:21,260 So our question bank ends on the last question 74 75 00:06:21,330 --> 00:06:30,210 and our app no longer goes forwards. But if we keep going, our question, even though we end on this one 75 76 00:06:30,300 --> 00:06:37,770 and it won't progress and our app won't crash, but notice down here we're still getting icons added depending 76 77 00:06:37,770 --> 00:06:39,900 on whether if we got this question right. 77 78 00:06:40,320 --> 00:06:44,810 So our quiz still hasn't fully ended. In order to fix this, 78 79 00:06:44,820 --> 00:06:50,190 we have a challenge for you. And once you're ready, I'll see you on the next lesson. 8569

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.