All language subtitles for 011 Shuffling a List_en

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
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 Download
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: 1 00:00:01,200 --> 00:00:05,910 In the last two sections, we customize the way in which the print function represented our deck of 2 00:00:05,910 --> 00:00:08,189 cards and individual card as well. 3 00:00:08,580 --> 00:00:11,790 So that kind of takes care of this print cards functionality right here. 4 00:00:12,360 --> 00:00:14,800 We're now going to move on to this shuffle function. 5 00:00:15,630 --> 00:00:20,520 You'll notice that any time we print out our list of cards right here, they all appear to be in order. 6 00:00:20,520 --> 00:00:26,670 So ACE two, three, four, five, and then starting over a two, three, four, five. 7 00:00:27,060 --> 00:00:30,840 So when we first create our deck of cards, they're all created in order. 8 00:00:31,410 --> 00:00:35,610 Well, definitely a lot of card games out there are all based on chance. 9 00:00:35,620 --> 00:00:39,960 And so we definitely need to have the ability to shuffle the cards in the deck or to randomize their 10 00:00:39,960 --> 00:00:40,350 order. 11 00:00:41,240 --> 00:00:46,820 Now, we certainly could write a little bit of logic by hand to customize the shuffling, but instead 12 00:00:46,820 --> 00:00:53,540 we're going to rely upon a standard library function to automatically shuffle the list of cards for 13 00:00:53,540 --> 00:00:53,840 us. 14 00:00:54,710 --> 00:01:00,080 So in this section, we're going to be focused not so much on how we shuffle cards, per say, but instead 15 00:01:00,080 --> 00:01:06,140 we're going to focus on looking up some of the standard documentation in the Dart API and get a better 16 00:01:06,140 --> 00:01:11,690 idea of how to read the documentation and use a lot of built-In functionality that is included with 17 00:01:11,690 --> 00:01:14,270 the dart language to get started. 18 00:01:14,300 --> 00:01:17,450 We're going to pull up the official dart API documentation. 19 00:01:18,020 --> 00:01:24,170 So inside of a new tab in my browser, I'm going to navigate to API darling Doug. 20 00:01:26,330 --> 00:01:31,700 Now, at the time of this video, Darte is still rolling out version two and version two is what we're 21 00:01:31,700 --> 00:01:33,770 using throughout this course of darte. 22 00:01:34,430 --> 00:01:36,880 When we go to API darte langue. 23 00:01:36,890 --> 00:01:39,800 At present, I see a page that looks like this right here. 24 00:01:39,950 --> 00:01:43,490 And this is the documentation for version one, two, four. 25 00:01:43,970 --> 00:01:46,720 Like I said, we are using DART to throughout this course. 26 00:01:47,120 --> 00:01:53,420 So if you see this page, you'll want to find this link right here and go to the version to documentation. 27 00:01:54,650 --> 00:01:58,980 So if you see a page that looks like this when you go to API darte langue, that's good. 28 00:01:59,030 --> 00:02:00,890 This is the version to documentation. 29 00:02:02,320 --> 00:02:07,810 So once we're here, you'll see on the left hand side a couple of different sections, these are all 30 00:02:07,900 --> 00:02:11,320 portions or modules in the dirt standard library. 31 00:02:12,490 --> 00:02:18,550 If you've ever worked with JavaScript before, JavaScript is known as a language that has a rather weak 32 00:02:18,550 --> 00:02:19,510 standard library. 33 00:02:19,730 --> 00:02:24,400 In other words, there's not a lot of built-In functionality in a lot of the different objects that 34 00:02:24,400 --> 00:02:25,030 you work with. 35 00:02:25,390 --> 00:02:29,860 And a lot of the time we end up having to write a lot of code from scratch to implement some very basic 36 00:02:29,860 --> 00:02:36,270 operations, very much unlike JavaScript, Dart has a very strong standard library. 37 00:02:36,730 --> 00:02:42,010 So in part, whenever you make use of it, there's a tremendous amount of pre generated code. 38 00:02:42,040 --> 00:02:47,020 I should say pre generated, but there's a lot of included code that we get for free just by using darts. 39 00:02:47,440 --> 00:02:52,690 And it means that we can lean on the standard library a little bit to take care of many standard operations 40 00:02:52,690 --> 00:02:57,010 that we might otherwise have to write up by hand if we were making use of something like JavaScript. 41 00:02:58,890 --> 00:03:03,930 So what we're looking for in particular here is the core module, I'm going to click on core on the 42 00:03:03,930 --> 00:03:04,740 left hand side. 43 00:03:06,250 --> 00:03:10,690 And then you'll notice on the right hand side, we get a listing of different classes, so these are 44 00:03:10,690 --> 00:03:14,290 all classes that are included in the core library of darte. 45 00:03:15,210 --> 00:03:19,970 If you scroll down a little bit on the right hand side, you'll find a class called List. 46 00:03:20,670 --> 00:03:25,700 So when you and I make our list of cards right now, we are creating an instance of a list. 47 00:03:26,340 --> 00:03:28,410 So if we look at the documentation for list. 48 00:03:30,290 --> 00:03:35,930 We can find a whole bunch of documentation about all the built in functionality that comes whenever 49 00:03:35,930 --> 00:03:37,040 we create a list. 50 00:03:37,630 --> 00:03:40,010 So in particular, we can scroll down a little bit. 51 00:03:40,670 --> 00:03:43,850 You'll find a list of all the different ways to create a list. 52 00:03:44,700 --> 00:03:49,790 You'll find a list of all the different properties that belong to the list, and then you'll see all 53 00:03:49,790 --> 00:03:52,140 the different methods that we get for free as well. 54 00:03:53,000 --> 00:03:55,460 We're going to come back to this documentation quite a bit. 55 00:03:55,580 --> 00:03:59,870 But in this case, we're going to scroll down right now just a little bit and go directly to the function 56 00:03:59,870 --> 00:04:00,830 we're going to use. 57 00:04:02,120 --> 00:04:03,020 All right, here we go. 58 00:04:04,210 --> 00:04:07,130 So right here is a function or a method called shuffle. 59 00:04:07,600 --> 00:04:14,860 So any time you create a list in darte, you automatically get access to this shuffle method right here. 60 00:04:15,490 --> 00:04:21,310 So if we take our card list or our list of cards that exists inside of our deck, so like this thing 61 00:04:21,310 --> 00:04:27,700 right here and we just call shuffle on it, it will automatically randomize the order of all the elements 62 00:04:27,700 --> 00:04:31,270 within that list and essentially accomplish what you and I are trying to do. 63 00:04:32,020 --> 00:04:33,390 So let's give this a shot. 64 00:04:33,850 --> 00:04:40,000 I'm going to flip back over to Arpad and I'm going to define a new method on my deck class. 65 00:04:40,180 --> 00:04:43,960 So underneath two string, I'm going to add a new method called Shuffle. 66 00:04:45,230 --> 00:04:51,350 And then inside of here, all we're going to do is call cards, dot shuffle, so cards dot shuffle. 67 00:04:52,470 --> 00:04:56,520 Cards is a reference to the list that belongs to our instance of the class. 68 00:04:57,560 --> 00:05:02,840 And then on that list object, we're going to call these shovel method, which is going to automatically 69 00:05:02,840 --> 00:05:05,360 randomize all the elements within that list. 70 00:05:06,500 --> 00:05:09,620 OK, so let's now try this out up inside the main function. 71 00:05:10,840 --> 00:05:16,600 After we create the deck, but before we print it, I'm going to call deck dot shuffle. 72 00:05:17,460 --> 00:05:23,910 So this will invoke the shuffle method on our instance of the class, which in turn is going to call 73 00:05:23,910 --> 00:05:31,110 the shuffle method on our cards list, we then print out the deck of cards and we should see them all 74 00:05:31,110 --> 00:05:32,310 randomized in order. 75 00:05:33,000 --> 00:05:33,960 So I click on Run. 76 00:05:36,050 --> 00:05:39,920 And then you'll notice that I now have five of diamonds, four of diamonds, three of spades, five 77 00:05:39,920 --> 00:05:43,000 of clubs, clearly the list right here has been randomized. 78 00:05:43,790 --> 00:05:47,750 OK, so in this section we started looking at the list documentation. 79 00:05:47,780 --> 00:05:48,800 Those include with DART. 80 00:05:48,950 --> 00:05:53,120 Like I said, we're going to be coming back to this documentation many times throughout this course 81 00:05:53,270 --> 00:05:57,890 and getting a better idea of how the standard library works, because they're going to be using the 82 00:05:57,890 --> 00:06:03,290 standard library quite a bit in just about every application that you create, much more so than if 83 00:06:03,290 --> 00:06:06,620 you're coming from a background in a language like, say, JavaScript. 84 00:06:07,370 --> 00:06:10,670 OK, so let's take a quick pause right here and we'll continue in the next section. 8913

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