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
The hard part is over now we're going to add what's left of the Big Three steps, as well as a copy
constructor in a two string.
And so we can use Intellisense to autocomplete, the gutters and setters, get a name, get phone number.
Get birthdates.
Get a age.
Set name.
That phone number said birthdates.
First, we're going to make that a private.
We need to hide this setar because the color shouldn't be allowed to use it.
The birthdate that they pass in should automatically determine the age, so inside set birth date.
So far it's fine, which it's just updating the birth dates, but it also needs to convert that date
into an age.
We've already done that.
So you might think they just copy and paste the code from the constructor right onto here.
But you know me, I'm not a big fan of copying and pasting code, we need that logic to be in one place.
So I'll create a function that returns an integer.
It's called to age and it receives a birth date as a parameter.
And inside the function, I'm going to cut and paste the logic from earlier.
In return, the.
The pass method throws a checked exception once again, don't catch the exception from inside the method.
Instead, the method is going to throw the exception to that.
Whoever is calling it handles the failure.
So back in the constructor.
The field is going to store the return value from the two major method.
And while the code looks so much better, I'm really glad we did this.
And now here inside set birthdates.
We're going to call Sage.
And will convert the birthdate to age and pass it in as an argument to basically when the caller updates
the birth date, it's going to automatically update the field as well.
But now to age throws a pass exception, but we're not going to try catch inside of our method.
Instead, the method is going to throw the exception to that.
Whoever is calling it, whoever is the one that's providing the birth dates, they need to be the ones
to handle the failure.
Before we go on, this is a good place to test our code.
I'm going to go back to Main.
Put this back to 07.
And update the birthdate.
Instead of 07 will say 08.
A lot of breakpoint right here.
I'll step over creating the object.
The contact variable star is a reference that points to the object here we update the object on step
inside, it updates the birth date.
I'm going to step over this line and here it updates the age.
But as you can see, a month, does it really make a difference?
So we'll change the year.
And there you go.
Updating the birthdate automatically updates the.
If we keep going, finally runs and prints, process completes, we're good so far.
The next step is that a copy constructor, because at some point we're going to need a way to copy contact
objects without falling into the reference trap so we can simply copy this constructor and instead of
parameters, will be obtaining values from a source object.
Then said every field in the current object equal to that field value from a source object, nothing
new here.
Let's visualize what's going on back in Maine, I'm going to create a new contact object that copies
every field from this one.
New contact.
Contact.
This points to the new contact object that we just created.
Soares points to the object that we passed in.
And one by one, we're copying every value from the source object into the current object.
The next task tells us that every class that models an object should have a two string method somehow
attached to string method to the class.
Public string.
To string and we'll copy over the format that I left you.
And will replace the placeholders where we need to.
And perfect, we're done creating the contact class, let's test it out inside mean I'm going to print
the object.
And everything works beautifully.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.