WEBVTT

00:00.780 --> 00:09.570
Let us now discuss about methods so methods are functions defined inside the body of a class.

00:09.960 --> 00:11.880
So this is the class.

00:12.180 --> 00:18.120
So what it will be are defining inside this, the functions which are defined inside this.

00:18.570 --> 00:20.790
These are called methods.

00:21.420 --> 00:27.260
Now, these are used to perform operations with the attributes of an object.

00:27.480 --> 00:36.120
So if I want to do certain operations, I want to print self-portrait or if I am trying to say I am

00:36.130 --> 00:36.680
Brindusa.

00:37.440 --> 00:43.590
So this is something which I'm trying to do with the attributes or if I want to modify certain that

00:43.920 --> 00:50.250
if I want to set a particular attribute, what I want to display a particular attribute or I want to

00:50.250 --> 00:56.340
do any other kind of operation, all of those things are done using these methods.

00:56.350 --> 01:08.730
Only now methods are a key concept of oops, and they are essentially used to divide the responsibilities

01:08.730 --> 01:09.980
into programming.

01:10.350 --> 01:16.650
Now, especially it is done in case of large applications, because in large applications you need a

01:16.650 --> 01:24.480
lot of structuring because then we have such large applications that are very small chunks which need

01:24.480 --> 01:27.070
to be created and then the same room together.

01:27.570 --> 01:34.080
So it is something like if you have a car, so again you will build the body will be the engine, you

01:34.080 --> 01:40.530
will put the brakes on the steering wheel and everything, and then finally you will combine them together.

01:40.530 --> 01:45.300
You will just plug them all together so that it could actually work.

01:45.780 --> 01:52.470
So these different parts which you have created, the body of the car, the engine of the car.

01:52.740 --> 01:55.050
These are different classes.

01:55.290 --> 01:57.860
So think of it as different classes.

01:58.050 --> 02:02.420
So we create all these different classes and then we combine them together.

02:02.430 --> 02:09.090
We just join them together and basically we connect them so that they can work in a better way.

02:10.590 --> 02:16.410
So this is what exactly is the use of these methods.

02:16.650 --> 02:24.840
And you can think of methods as a function which is acting on an object that takes the object itself

02:24.840 --> 02:27.420
into the account through itself argument.

02:27.570 --> 02:32.710
So what we are doing is we are basically taking the object itself.

02:32.970 --> 02:42.960
So when we talk about this self here, so if you see the name defining a particular method I'm putting

02:42.960 --> 02:47.410
in this self here, what does this mean?

02:47.550 --> 02:52.650
This means that I am trying to put in the object inside this.

02:53.700 --> 03:00.090
So I'm telling the method that, okay, this is the object which I am talking about, and you need to

03:00.090 --> 03:04.600
work on the attributes which are associated with this particular object.

03:05.070 --> 03:08.840
So this will actually help the internal.

03:08.850 --> 03:09.220
Okay.

03:09.240 --> 03:13.230
This is the object which I need to work on now, whatever I have.

03:13.260 --> 03:20.280
So if I have some bried, which I'm talking about, the GM talking about, this breed is actually belonging

03:20.280 --> 03:22.910
to the object, which I am being called for.

03:23.880 --> 03:33.090
So when I'm seeing Don Dog Breed or us, let's say assembled printer, so here the standard print of

03:33.090 --> 03:40.380
this printed function, this printer method actually gets to know that the object which it needs to

03:40.380 --> 03:42.330
work on is actually some.

03:43.410 --> 03:49.020
So whatever attribute is related to some that is, let's say here it's Labbe.

03:49.320 --> 03:57.750
So this means that this printer needs to work with the attribute which is associated with some which

03:57.750 --> 04:04.800
could be the Labrador or any other details, maybe the name of the dog, the breed of the dog, how

04:04.800 --> 04:09.800
the dog barks with the image of the dog, almost anything which is associated with the dog.

04:10.080 --> 04:19.050
The function will work on that particular thing because it has been called on the object itself.

04:20.340 --> 04:23.730
So now you understand why we actually put in the self here.

04:24.030 --> 04:29.460
If we want to put this self, the function would this method will not get to know that.

04:29.910 --> 04:32.860
What am I supposed to walk upon which I attribute?

04:32.940 --> 04:34.410
Am I supposed to work upon.

04:34.620 --> 04:40.170
So it works on the self, not any other attribute which it has.

04:40.180 --> 04:46.330
So it will get to know that, OK, if I am talking about X object then the name of X object.

04:46.330 --> 04:49.860
They need to work on the edge of this X object to work.

04:50.640 --> 04:50.960
OK.

04:52.120 --> 04:59.920
So let's get for the and let's call it something so that you get a better understanding of it.

05:00.670 --> 05:05.470
So now what we will be doing is let us create something.

05:10.070 --> 05:10.260
Didn't.

05:12.340 --> 05:15.190
Now, let me create a class.

05:19.350 --> 05:25.020
I named this class as so good, so this is my so-called class now.

05:25.050 --> 05:32.610
This class will contain by which is a constant value right now.

05:32.620 --> 05:35.730
The value of PI does not change based on the object.

05:36.030 --> 05:39.930
No matter which circle I'm creating, the value of by will still remain the same.

05:40.200 --> 05:45.180
So that is why I'll give it the value outside the method.

05:46.810 --> 05:50.040
OK, now we will be creating the circle.

05:50.040 --> 05:55.350
So whenever I'm creating the circle, I need to provide the radius to put it OK.

05:55.920 --> 05:59.150
Unless we provide the radius, this will be cannot be created.

05:59.400 --> 06:05.260
So I'm creating a diff for init function, so I'm initializing.

06:06.720 --> 06:10.270
So this is the sensation of the circle.

06:10.530 --> 06:16.890
So I am doing it with self because Salafism is a military.

06:17.220 --> 06:24.680
Then I put in the radius and I give some default value to the circle.

06:24.690 --> 06:29.840
So let's see if my user does not provide any value to the circle.

06:30.240 --> 06:35.300
If the user is not providing any radius, then my program will actually throw an error.

06:35.580 --> 06:39.090
I don't want that to happen, so I'll give it the default value to say one.

06:40.320 --> 06:43.520
And furthermore, I have to

06:47.400 --> 06:51.060
now I will instantiate the value choice itself.

06:51.450 --> 06:56.820
The radius is equal to radius.

06:57.780 --> 07:03.090
So this means that I'm giving the value of this particular value, whatever the user is providing to

07:03.090 --> 07:04.290
self-taught radius.

07:04.830 --> 07:08.840
And in case the user does not provide anything, then it takes one by default.

07:10.110 --> 07:22.470
Next, what I do is I say self taught area is equal to radius into radius in two.

07:27.060 --> 07:29.310
So good not.

07:31.650 --> 07:38.020
So when I say the so-called outby so it understands that whatever value is associated with my class

07:38.020 --> 07:41.120
Sokal, I want to access that particular value.

07:41.580 --> 07:44.440
So I'll go ahead and I will define my next function.

07:44.460 --> 07:46.690
So next function is separate.

07:46.860 --> 07:51.000
So I'm trying to set the radius or else is it radius?

07:52.650 --> 08:02.700
And I live within self again because it is a military thing and I have seen you underscore already and

08:02.700 --> 08:16.230
I go for two and I say self thought radius is equal to you radius.

08:17.070 --> 08:24.480
So what I'm doing is when I when the user will be calling said radius, the user will provide the new

08:24.480 --> 08:24.990
radius.

08:25.260 --> 08:32.130
So with the new radius I will put the value of new radius in the radius which is belonging to that particular

08:32.130 --> 08:33.920
object that I am being supported.

08:33.930 --> 08:38.100
It is right next to it to set up the area.

08:39.480 --> 08:41.250
So what will be the area.

08:41.250 --> 08:45.020
Area would be radius square in two.

08:45.420 --> 08:51.010
But I it it's so it's basically by our square.

08:51.030 --> 08:51.900
So I would say.

08:55.310 --> 09:12.430
New radios into a new year and do so don't buy or Wiggins's self-taught, buy one and the same thing.

09:13.130 --> 09:16.330
No difference you would have written.

09:16.850 --> 09:21.770
Self-taught radio is also here, then that would also have not made any difference.

09:22.970 --> 09:24.090
Just one in the same thing.

09:24.710 --> 09:29.210
Next, I'll create a method defined, so confident.

09:29.210 --> 09:32.510
So I get the

09:35.090 --> 09:42.020
parents and I put myself here because I don't need to provide anything for that.

09:42.360 --> 09:44.090
I use the existing values.

09:44.480 --> 09:47.030
So I was just written

09:49.670 --> 09:57.170
self-taught shadiest and two self-taught by.

09:59.590 --> 10:09.460
In doing so, basically, Dubai are is so confident they so this is what we have next, what we will

10:09.460 --> 10:12.980
do is we will create a surplus.

10:12.980 --> 10:15.760
So let's say my circle is see, I'm creating it.

10:16.120 --> 10:18.220
I'm just creating an object of it.

10:18.220 --> 10:19.100
So I didn't say so.

10:21.070 --> 10:22.330
And I do this.

10:22.480 --> 10:27.790
So once I do this now, so go for this circle.

10:27.790 --> 10:29.240
I'm not giving any argument.

10:29.260 --> 10:33.830
So it does by default, consider that it is equal to one right now.

10:33.880 --> 10:36.250
Let me bring my friend

10:39.070 --> 10:40.390
radius.

10:42.250 --> 10:44.470
So radius is

10:47.380 --> 10:48.920
C dot

10:51.070 --> 10:52.060
radius.

10:52.630 --> 10:54.120
Radius is not radius.

10:54.370 --> 10:57.780
So basically I'm using the object to call the attribute.

10:58.960 --> 11:03.320
Next I need to do the same for area and circumference.

11:03.730 --> 11:04.810
So I would say

11:07.960 --> 11:13.690
area is C area

11:17.260 --> 11:17.860
and.

11:24.740 --> 11:27.160
S c dot.

11:27.470 --> 11:31.950
Now, I need to call this function to get the circumference right.

11:32.360 --> 11:37.510
So I'll just get this from you and I will run this.

11:37.970 --> 11:40.950
So when I run this, I want to get the details accordingly.

11:41.600 --> 11:42.010
Right.

11:43.910 --> 11:45.240
So here I have it.

11:45.560 --> 11:51.110
So the radius comes out to be one area comes to me, three point one for circumference comes out to

11:51.110 --> 11:52.110
be six point to it.

11:52.700 --> 11:57.820
So here what we have done is we have created the instantiation function.

11:58.190 --> 12:04.430
This method will actually allow us to instantiate once this particular command is run.

12:04.730 --> 12:08.390
So once we run this, this will run by default.

12:09.470 --> 12:17.450
Then when I get these dot radius reload a.D.A, I can easily get those because these are available and

12:17.450 --> 12:19.580
these are attributes which are belonging to so good.

12:19.640 --> 12:23.120
I can easily get them for the object respectively.

12:23.130 --> 12:32.210
So if I have some other object, let me copy this and I'd just run this full circle with latitude.

12:33.010 --> 12:41.030
OK, I just run this so you can see the values are updated and I've got the new ones now again let me

12:41.030 --> 12:46.100
do this and make it as easy to OK and let me create this.

12:46.100 --> 12:47.110
I see one.

12:48.770 --> 12:56.150
So when I run this so you see we have seven we have to do now if I want to get the value for see one

12:56.150 --> 12:56.470
again.

12:56.480 --> 12:58.510
So I think this is even not area.

12:59.390 --> 13:01.210
So you see the value still exists.

13:01.370 --> 13:02.600
It has not been over.

13:12.560 --> 13:13.250
Just don't.

13:22.330 --> 13:28.730
Right now is you can see it to see one has this particular area.

13:28.780 --> 13:33.950
And same thing comes out here, right?

13:34.270 --> 13:44.380
So this is how we will be walking with these now in this anonymity here in order to calculate the area

13:44.380 --> 13:50.260
to be we we to go so blue dot by now we have done this upload by now.

13:50.270 --> 13:55.020
This is because the object does not yet have its own dot by active route.

13:55.540 --> 13:58.990
OK, because right now it has not been created.

13:59.050 --> 14:06.330
OK, once we create this once object of the circle has been created, then this attribute will come

14:06.340 --> 14:06.970
individual.

14:07.330 --> 14:07.690
Right.

14:07.960 --> 14:11.650
So we call this class object attribute fire instead.

14:11.830 --> 14:14.470
OK, so we are using this class attribute.

14:14.510 --> 14:20.670
OK, now in the set radius method, we will be working with an existing Sopel object.

14:20.680 --> 14:20.980
Right.

14:21.400 --> 14:27.400
So when we work on this one, we are already working with an existing Sobol object.

14:27.760 --> 14:29.080
We have the SILVERGLATE.

14:29.590 --> 14:31.490
So this is the reason why.

14:31.510 --> 14:44.710
Now here what happens is now we actually have a fire attribute already existing for this particular

14:44.710 --> 14:46.270
class, this object.

14:46.270 --> 14:48.670
But I'm using FF7 now.

14:48.670 --> 14:55.600
This favella will be existing, but for the very first time when I'm not creating any object at that

14:55.600 --> 15:00.700
time, the circle object is not present because of the classes when it and that is the reason why I'm

15:00.700 --> 15:01.020
using.

15:01.040 --> 15:03.550
So I'm here and I'm using Selldorff by.

15:04.730 --> 15:10.890
Fine here, you could have you so called out by also, but here, if you will be using said goodbye,

15:10.890 --> 15:11.470
it won't work.

15:11.750 --> 15:23.030
OK, OK, so let us see if we change the radius so you can see when we change the radius, things come

15:23.030 --> 15:24.260
out fine.

15:24.800 --> 15:30.680
So here you would have understood that how we use the cell operator.

15:31.280 --> 15:31.650
Right.

15:32.870 --> 15:37.440
So now let's go ahead with the inheritance.

15:37.440 --> 15:41.120
So we will be learning about inheritance in the next session.

15:41.450 --> 15:41.900
Thank you.
