Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
There were two parts of the building, blackjack in part.
One was to set up the logic for starting the game.
The first task was to make a function that returns a random number between one and 13.
Like always, it's going to be public static.
It returns an integer.
The function is called draw random card, and it doesn't take any parameters.
Now, returning a random number between a certain range is something we've done a million times.
First, we use Mathurin, him to get a random decimal from zero to less than one.
And multiplying the result by 13 is going to scale the range from zero to less than 13.
We can add one to the random number to scale the range from one to less than 14.
And then typecasting, double to end cuts off the decimal and returns a whole number from one to 13,
a fairly simple task.
The second task is to make a function that returns a string drawing of the card, as always, its public
static.
And this one returns a string.
And it takes one parameter, an integer that represents a card number.
When you call this function, it's going to receive an integer value and we have to match that integer
value to a card, so we'll use a switch statement to compare the card number against the list of 13
cards.
And don't forget the usual default case.
Because in the event that a random number doesn't match any of our cases, we need the default case
to return a string value as well.
It's simply going to return a string that says not possible.
And for each case, I'm going to return the corresponding cards drink, this is a long process, as
you saw in poker.
Orito So I'm going to fast forward the video because I trust that by now you should know how to do it.
OK, that's over, I'm going to do some cleaning up.
And task three, this one tells us that the user needs to press enter to start the game, some not Eskandar
next line after putting the welcome messages.
And notice that I declared scanner at the level of the class, instead of declaring it in the main method,
you'll find out one part two.
But that doesn't matter because we declared our scanner variable at the level of the class, which means
we can access it from anywhere inside the class section or in our code for now, because we've written
so much.
Let's make sure everything is OK.
OK, so far, nothing interesting.
Now we need to move on to task for to test our function.
When the game starts, the player gets two cards face up so we can use draw a random card to get two
random cards.
Now, each function call is going to return a random integer value between one and 13 into the next
step is to print the string representation of each card.
What I'll do is I'll print you get a new line.
And we can use card strength to return a string drawing of the first card number.
We'll copy this as well.
And connect a string drawing of the second card.
Let's run our code.
And I got a seven and a two.
OK, task five, which is to print the player's hand value, in other words, we need to add up the
value of each card into a total.
So int total.
Is equal to the value of card one plus the value of card to.
Your total is.
Connecting the players total hand value.
Easy right Netrunner code.
Remember that face cards, Jack Queen King should have values of 10, but currently your code treats
Jack Queen and King as 11, 12 and 13.
In this case, the queen is a 12 and three plus 12 is 15.
In the instructions, I give you a hint and it was to use my thought men, because if you look at the
Java documentation, there are four versions of the main function we can use.
Map thought meant to take to integer values and return the smaller of the two.
So here we can use my Damon to get the smaller value between the card number and 10, we'll get the
smaller value between a card one and 10 plus Matt Damon getting the smaller value between card two and
10.
If you run this code.
It's clear that JAV accounts face value this 10 because seven plus 10 is 17.
Think about what happened.
My first card was a seven.
And the minimum value between seven and 10 is seven.
And my second card was a king, which is 13, and the minimum value between 13 and 10 is 10.
In essence, what Matt Damon is doing is it's reducing any card value that is 11, 12 or 13, back down
to 10.
And so from an animation perspective, the two arguments are the card number intent, if the card number
is bigger than 10 men returns 10.
If the card number is smaller than 10 million returns, the card number.
And if the card no intent or equal means simply returns 10.
Like men, there are many other built in functions that make our coding lives easier.
It's up to you to look them up.
And now the dealer gets two cards as well.
This is going to follow a very similar process.
Once again, we use draw random card to get two random cards, but this time for the dealer, dealer,
card one and dealer card to.
Each function call is going to return a random integer value between one in 13 and like before we're
going to print the string representation of each value.
So I'll print a new line.
The dealer shows new line.
And print the first card string.
Followed by a new line.
And if you remember, the dealer's cards needs to be facing down or his second card, for that matter,
so inside your workbook, I left you a function called Face Down that returns a face down card.
So we're going to call this function and print the return value, because we don't want to show the
dealer second card just yet.
And just like before, we're going to calculate the dealer's hand value with simply odds, their first
card by the second.
And remember, we're going to use my thumb and to make sure that face values don't get counted as 11,
12 or 13.
OK, so we have the dealer's total, but until the game actually starts, we're going to hide it.
So here, I'll print.
The dealer's total is hidden.
All right, that's all for part one, it's time to run the code one final time.
And to no surprise, I get two cards, so does the dealer.
But instead of printing their second card, we're printing a face down card because we don't intend
on showing it just yet.
All right, that is all.
I'll 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.