All language subtitles for 044 Contacts – Part 2 (Solution)_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:00,240 --> 00:00:04,470
The hard part is over now we're going to add what's left of the Big Three steps, as well as a copy
2
00:00:04,470 --> 00:00:05,820
constructor in a two string.
3
00:00:09,100 --> 00:00:15,190
And so we can use Intellisense to autocomplete, the gutters and setters, get a name, get phone number.
4
00:00:18,030 --> 00:00:19,350
Get birthdates.
5
00:00:21,510 --> 00:00:22,560
Get a age.
6
00:00:23,560 --> 00:00:24,520
Set name.
7
00:00:26,480 --> 00:00:29,210
That phone number said birthdates.
8
00:00:33,780 --> 00:00:35,760
First, we're going to make that a private.
9
00:00:39,060 --> 00:00:42,900
We need to hide this setar because the color shouldn't be allowed to use it.
10
00:00:43,920 --> 00:00:49,580
The birthdate that they pass in should automatically determine the age, so inside set birth date.
11
00:00:49,620 --> 00:00:54,750
So far it's fine, which it's just updating the birth dates, but it also needs to convert that date
12
00:00:54,750 --> 00:00:55,450
into an age.
13
00:00:55,920 --> 00:00:57,170
We've already done that.
14
00:00:57,720 --> 00:01:01,530
So you might think they just copy and paste the code from the constructor right onto here.
15
00:01:06,400 --> 00:01:11,730
But you know me, I'm not a big fan of copying and pasting code, we need that logic to be in one place.
16
00:01:13,430 --> 00:01:15,740
So I'll create a function that returns an integer.
17
00:01:19,690 --> 00:01:23,260
It's called to age and it receives a birth date as a parameter.
18
00:01:29,000 --> 00:01:32,270
And inside the function, I'm going to cut and paste the logic from earlier.
19
00:01:40,920 --> 00:01:41,760
In return, the.
20
00:01:49,070 --> 00:01:54,380
The pass method throws a checked exception once again, don't catch the exception from inside the method.
21
00:01:55,040 --> 00:01:57,410
Instead, the method is going to throw the exception to that.
22
00:01:57,410 --> 00:01:59,510
Whoever is calling it handles the failure.
23
00:02:04,640 --> 00:02:05,810
So back in the constructor.
24
00:02:11,190 --> 00:02:14,460
The field is going to store the return value from the two major method.
25
00:02:18,230 --> 00:02:21,320
And while the code looks so much better, I'm really glad we did this.
26
00:02:23,770 --> 00:02:25,900
And now here inside set birthdates.
27
00:02:27,680 --> 00:02:29,090
We're going to call Sage.
28
00:02:33,350 --> 00:02:39,440
And will convert the birthdate to age and pass it in as an argument to basically when the caller updates
29
00:02:39,440 --> 00:02:42,740
the birth date, it's going to automatically update the field as well.
30
00:02:43,340 --> 00:02:47,810
But now to age throws a pass exception, but we're not going to try catch inside of our method.
31
00:02:48,200 --> 00:02:50,690
Instead, the method is going to throw the exception to that.
32
00:02:50,690 --> 00:02:55,820
Whoever is calling it, whoever is the one that's providing the birth dates, they need to be the ones
33
00:02:55,820 --> 00:02:56,890
to handle the failure.
34
00:02:59,900 --> 00:03:02,450
Before we go on, this is a good place to test our code.
35
00:03:02,480 --> 00:03:03,650
I'm going to go back to Main.
36
00:03:06,860 --> 00:03:08,330
Put this back to 07.
37
00:03:11,580 --> 00:03:13,020
And update the birthdate.
38
00:03:20,530 --> 00:03:22,510
Instead of 07 will say 08.
39
00:03:25,560 --> 00:03:27,060
A lot of breakpoint right here.
40
00:03:34,630 --> 00:03:36,610
I'll step over creating the object.
41
00:03:38,900 --> 00:03:44,600
The contact variable star is a reference that points to the object here we update the object on step
42
00:03:44,600 --> 00:03:47,140
inside, it updates the birth date.
43
00:03:47,150 --> 00:03:50,410
I'm going to step over this line and here it updates the age.
44
00:03:50,960 --> 00:03:53,270
But as you can see, a month, does it really make a difference?
45
00:03:53,270 --> 00:03:54,410
So we'll change the year.
46
00:04:17,310 --> 00:04:18,070
And there you go.
47
00:04:18,120 --> 00:04:20,399
Updating the birthdate automatically updates the.
48
00:04:23,390 --> 00:04:28,100
If we keep going, finally runs and prints, process completes, we're good so far.
49
00:04:32,940 --> 00:04:37,800
The next step is that a copy constructor, because at some point we're going to need a way to copy contact
50
00:04:37,800 --> 00:04:43,320
objects without falling into the reference trap so we can simply copy this constructor and instead of
51
00:04:43,320 --> 00:04:46,440
parameters, will be obtaining values from a source object.
52
00:04:51,390 --> 00:04:56,400
Then said every field in the current object equal to that field value from a source object, nothing
53
00:04:56,400 --> 00:04:56,880
new here.
54
00:05:06,790 --> 00:05:11,290
Let's visualize what's going on back in Maine, I'm going to create a new contact object that copies
55
00:05:11,290 --> 00:05:12,520
every field from this one.
56
00:05:17,580 --> 00:05:18,480
New contact.
57
00:05:20,160 --> 00:05:20,820
Contact.
58
00:05:36,420 --> 00:05:39,450
This points to the new contact object that we just created.
59
00:05:43,300 --> 00:05:45,670
Soares points to the object that we passed in.
60
00:05:48,580 --> 00:05:52,770
And one by one, we're copying every value from the source object into the current object.
61
00:05:58,260 --> 00:06:03,180
The next task tells us that every class that models an object should have a two string method somehow
62
00:06:03,180 --> 00:06:04,950
attached to string method to the class.
63
00:06:07,180 --> 00:06:08,350
Public string.
64
00:06:13,000 --> 00:06:16,620
To string and we'll copy over the format that I left you.
65
00:06:23,070 --> 00:06:25,350
And will replace the placeholders where we need to.
66
00:06:46,890 --> 00:06:52,110
And perfect, we're done creating the contact class, let's test it out inside mean I'm going to print
67
00:06:52,110 --> 00:06:52,830
the object.
68
00:07:05,110 --> 00:07:06,850
And everything works beautifully.
6331
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.