Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed C# Objects!
You have completed C# Objects!
Preview
Throw an exception to indicate that a method can't complete successfully.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
that doesn't exist on the map.
0:00
The natural place to do this
validation is here in the constructor
0:00
because the constructor is called
when the object is created.
0:03
So we can actually stop
the object from being created
0:07
by causing this method to fail.
0:09
In order to do this validation,
0:12
the constructor will need to have
an instance of the map object.
0:13
So we'll add it to the list
of parameters here.
0:17
Now we can check this map location is
on the map by typing if map.OnMap and
0:20
then pass it this, open and
closing curly brace.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up