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
An encapsulation strategy is to only allow indirect access to fields with getter and setter accessor methods.
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
We can start to code it up now.
0:00
One attribute the invader should
have is its location on the map.
0:01
We need this in order to determine
how close they are to towers,
0:05
to see if they're in range of each other.
0:08
Let's add a MapLocation field to
the invader class and call it Location.
0:11
It'll need to be public so the other
classes can get the invader's location.
0:17
And it can't be read only because
the location changes throughout the game.
0:21
Generally it's a bad idea
to make fields public
0:25
because this exposes too much of
the internal workings of the class.
0:28
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