All language subtitles for 002 Solution - Part 1_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
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

Original subtitles

In this lesson, we're going to go through the solution to part one of building rock, paper, scissors.

Remember, the first task is to see if the user wants to play and we can pick up the user's answer using

scanned next line.

So we'll set a variable already is equal to scan.

Next line.

And that's really it.

I'm going to run my coat after each task because it's a good habit to keep testing your coat.

And it looks like the OP starts by asking the user if they want to play, to which we reply yes.

So far, so good.

Now, test tube was to set up the game, and so if the user enters, yes, we can start by setting up

the game, that is, if the answer is stored inside the ready variable.

Equals, yes.

We're going to print a new line.

Great, then we'll print rock, paper, scissors shoots.

Otherwise else.

We'll print Dan's some other time.

Now the game starts after rock, paper, scissors, shoot, so here the user needs to choose between

a rock, paper, scissors, and we can easily pick up the user's choice with scanned next line.

And that's all task to I can now safely delete it because we're done.

And all of these tasks are going to be done inside the if statement, so I'm going to move them here.

OK, I'm going to run a test case.

Where the user says yes.

I'll choose rock and good this worked out.

Now I'm going to run a test case where the user says anything else.

And it prints Darren some other time.

The app is coming together so we can move on to task three.

The next step is to write a function, it's going to let the computer pick randomly between rock, paper,

scissors, if you look at the instructions, it returns a string and takes no parameters.

So we'll say public static string.

The function is called computer choice, and inside the function, the first instruction is to pick

a random number between zero and two.

The first, I can use math at random to get a random decimal from zero to less than one.

And we can multiply the result by three to scale the range from zero to less than three, essentially

from zero to less than two.

So we'll make a comment that says it returns a number between zero and less than three.

We can convert this number to an integer by typecasting the double tint.

This is going to cut off all the decibels and so the integer variable is going to carry any hole number

between zero and less than three.

In other words, from zero to two.

And so the next step is to compare the random integer value against three cases, so we'll make a switch

statement that compares the random integer.

Against the three possible integers that it could be zero.

In case, Tim.

If it matches case zero, return the string rock.

Return paper for case one.

And scissors for case to.

And as always, we need to add a default case.

We're in we're just going to return an empty string because it's impossible for the injured to be any

number other than zero one or two.

So I don't expect default to ever run.

But we need to put it anyway because the function expects a return value no matter what.

OK, that's all we need for our function.

I can now call the function from Main.

And this function call is going to return a random string that can be rock, paper, scissors, and

we're going to store that value in a variable called computer choice.

OK, finally, we can test our code by putting in two temporary print statements, I'm going to print

first, I'll insert a new line of space for aesthetic purposes.

Then I'll say you chose Colon and I'll put a tab of space between the string and the value that you

chose.

I'll do another print.

We're all say the computer chose.

Colin and I'll put a tab of space between this string and the random value returned by the computer.

OK, we can perform a final test.

And that prince, my choice, as well as the computer's choice, I'm going to keep running my code and

as I'm doing that, the computer keeps picking random choices, which is what you'd expect from a game

of rock, paper, scissors.

OK, so the next step is to compare your choice against the computer's choice and then you're going

to write code that determines the winner of the game.

See you in part two.

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