Bummer! That Track couldn't be located. Perhaps one of the Tracks below is what you're looking for?
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 Java Objects!
You have completed Java Objects!
Preview
Let's create a method that changes the internal state of our object
Learn more
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
Thinking through these limits
is always a good practice to fall into
0:00
as you start modeling objects.
0:02
Now, let's see.
0:04
We want to store some state, right?
0:05
We want to store how many Pez
are actually in the dispenser.
0:07
So that's an int field, right?
0:10
And we will name that PezCount.
0:12
We don't really want anyone
to change this,
0:16
So a good practice for
that is to keep it private
0:18
until you have a reason
to expose it to your consumers.
0:20
So we'll make this private.
0:24
If you aren't sure,
0:25
always start with private, switching
to public only when you have a need.
0:26
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