1
00:00:04,620 --> 00:00:08,340
The next part, which I'll be working on, is encapsulation.

2
00:00:09,390 --> 00:00:16,760
Now supposing we have our square smiley and then yeah, we have happy that side.

3
00:00:16,770 --> 00:00:23,880
We put this to see it around this you see how the hand area turns at 64 because we've modified a side

4
00:00:24,060 --> 00:00:24,510
to it.

5
00:00:25,860 --> 00:00:32,990
But many times we don't want this kind of direct modification of class attributes externally.

6
00:00:33,540 --> 00:00:38,760
So what we could do is we could make this attribute private.

7
00:00:38,940 --> 00:00:45,420
And to do that, we could add this double underscore before the variable name.

8
00:00:45,720 --> 00:00:50,820
So that will make this private modify it whereby it's to be used again.

9
00:00:50,820 --> 00:01:00,330
We have that around now we see from this that even after modifying this site, we will have the same

10
00:01:00,660 --> 00:01:01,830
value for the area.

11
00:01:02,100 --> 00:01:08,490
And that's because this side is taking the default value, which is this five here.

12
00:01:08,820 --> 00:01:11,880
And so external modifications are now allowed.

13
00:01:13,920 --> 00:01:20,970
And if we want to make this kind of external modifications, we could use a setter by setter would mean

14
00:01:20,970 --> 00:01:25,500
we could have would define this set side function.

15
00:01:28,430 --> 00:01:33,140
Which modifies the value of the site internally.

16
00:01:33,680 --> 00:01:38,390
So we don't have to modify this site value externally, but now internally.

17
00:01:38,720 --> 00:01:46,430
So yeah, we have this, it'll take this site, I will pass and you know, set the site.

18
00:01:47,780 --> 00:01:52,940
Obviously we have the self that's an object class, it's an object method.

19
00:01:53,120 --> 00:01:54,020
So we have that.

20
00:01:54,140 --> 00:01:56,390
We have the site we can now modify.

21
00:01:56,780 --> 00:01:58,550
Let's run this again, see that.

22
00:01:58,910 --> 00:02:06,200
Now what we do now is we have happy that said side and run it and you see that it's modified.

23
00:02:06,530 --> 00:02:10,370
So this is how we go about encapsulating.
