All language subtitles for 021 Shopping Cart – Part 4 (Tasks 2 and 3)_en
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
Hungarian
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,580 --> 00:00:06,680
For this solution to recovery tasks, two and three, the next Castells is to make sure tax is calculated
2
00:00:06,680 --> 00:00:07,190
correctly.
3
00:00:12,330 --> 00:00:14,640
I'm going to read a unit has named taxes valid.
4
00:00:22,110 --> 00:00:25,440
In our test asserts the tax were expecting three point nine.
5
00:00:29,450 --> 00:00:34,430
Is equal to the tax that gets returned when we pass a 30 dollar subtotal and to get tax.
6
00:00:42,280 --> 00:00:46,480
And now inside cadaverine to write code to make the test fail public double.
7
00:00:47,780 --> 00:00:48,620
Get tax.
8
00:00:50,900 --> 00:00:51,950
Double subtotal.
9
00:00:55,220 --> 00:00:56,800
And I'm going to return fire for now.
10
00:01:02,970 --> 00:01:04,599
Run the unit test, then it fails.
11
00:01:04,800 --> 00:01:05,190
Good.
12
00:01:06,270 --> 00:01:08,550
Now we just write code to make sure it passes.
13
00:01:13,700 --> 00:01:18,440
I'm going to multiply subtotal by point one three, because that is the tax rate from the requirements
14
00:01:18,980 --> 00:01:24,530
and ideally the test should pass, but it doesn't because double digit keeps going on forever when you
15
00:01:24,530 --> 00:01:25,260
multiply them.
16
00:01:25,280 --> 00:01:27,410
However, we only want two decimal places.
17
00:01:32,280 --> 00:01:35,400
So we're going to create a new object of the decimal format class.
18
00:01:45,700 --> 00:01:49,360
And decimal format is going around our double to two decimal places.
19
00:01:52,500 --> 00:01:57,810
And to remember that decimal format objects have a format method they can call that converts our number
20
00:01:57,840 --> 00:02:02,070
or that around is our number, I should say, to the expected number of decimal places.
21
00:02:07,950 --> 00:02:13,710
However, it returns a string and you'll also remember that the rapper double has a past double method.
22
00:02:17,470 --> 00:02:20,470
Pass double passes a decimal value out of a string.
23
00:02:23,410 --> 00:02:24,550
Let's rerun the test.
24
00:02:28,170 --> 00:02:32,100
And it passes awesome, can this code be any simpler?
25
00:02:32,550 --> 00:02:38,640
Nope, so we're done refactoring onto the next case of our unit test is going to make sure the total
26
00:02:38,640 --> 00:02:39,750
calculates correctly.
27
00:02:45,580 --> 00:02:48,280
So I'm going to create a unit test named Total as valid.
28
00:02:56,450 --> 00:03:00,980
An artist is going to assert the total we're expecting ninety six point six seven.
29
00:03:06,220 --> 00:03:11,470
Is equal to the total that gets returned when we pass in a subtotal of eighty five point fifty five.
30
00:03:12,740 --> 00:03:15,110
And attacks of eleven point one to.
31
00:03:18,570 --> 00:03:24,600
OK, now back in Kageyama, I'm going to write code to make our test fail public double get total.
32
00:03:29,270 --> 00:03:31,580
They received the subtotal and attacks.
33
00:03:34,270 --> 00:03:35,680
Inside will return zero.
34
00:03:39,850 --> 00:03:41,320
Let's make sure the test fails.
35
00:03:46,580 --> 00:03:52,850
It does now good to write code to make it pass, which would just be us returning the addition of both
36
00:03:52,850 --> 00:03:55,580
parameters around the unit test.
37
00:04:01,020 --> 00:04:02,760
And it passes gret.
38
00:04:05,630 --> 00:04:07,520
Is there anything else we can do here?
39
00:04:07,820 --> 00:04:09,950
I doubt I can get any simpler than this.
40
00:04:11,500 --> 00:04:16,180
All right, we don't have any more methods to unit test, but we still haven't fulfilled this requirement.
41
00:04:16,209 --> 00:04:17,709
We need to return a receipt.
42
00:04:23,190 --> 00:04:27,360
So what I'm going to do is find a method named Checkout's that returns a string.
43
00:04:32,170 --> 00:04:37,090
And it's going to return a receipt that calls every method we just created, I'm sure there's a template
44
00:04:37,090 --> 00:04:38,050
we can copy over.
45
00:04:41,760 --> 00:04:45,270
And here it is, and it's already been done for us, that's pretty cool.
46
00:04:49,600 --> 00:04:53,800
There's nothing to unit test here, it's just a string, so we're all done part for it.
47
00:04:54,040 --> 00:04:58,840
But I want you to compare the old code that we wrote in the previous section to the one we have right
48
00:04:58,840 --> 00:04:59,170
now.
49
00:04:59,680 --> 00:05:03,100
This code isn't good because it performs way too many tasks.
50
00:05:03,440 --> 00:05:05,740
Our other methods are very long and messy.
51
00:05:08,370 --> 00:05:11,680
This code is also impossible to test, so it's vulnerable to bugs.
52
00:05:12,090 --> 00:05:13,980
Our new code is more polished.
53
00:05:13,980 --> 00:05:15,840
Each method performs one task.
54
00:05:15,840 --> 00:05:18,330
Each method is modular, and it's easy to test.
5109
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.