Let us now discuss about methods so methods are functions defined inside the body of a class.
So this is the class.
So what it will be are defining inside this, the functions which are defined inside this.
These are called methods.
Now, these are used to perform operations with the attributes of an object.
So if I want to do certain operations, I want to print self-portrait or if I am trying to say I am
Brindusa.
So this is something which I'm trying to do with the attributes or if I want to modify certain that
if I want to set a particular attribute, what I want to display a particular attribute or I want to
do any other kind of operation, all of those things are done using these methods.
Only now methods are a key concept of oops, and they are essentially used to divide the responsibilities
into programming.
Now, especially it is done in case of large applications, because in large applications you need a
lot of structuring because then we have such large applications that are very small chunks which need
to be created and then the same room together.
So it is something like if you have a car, so again you will build the body will be the engine, you
will put the brakes on the steering wheel and everything, and then finally you will combine them together.
You will just plug them all together so that it could actually work.
So these different parts which you have created, the body of the car, the engine of the car.
These are different classes.
So think of it as different classes.
So we create all these different classes and then we combine them together.
We just join them together and basically we connect them so that they can work in a better way.
So this is what exactly is the use of these methods.
And you can think of methods as a function which is acting on an object that takes the object itself
into the account through itself argument.
So what we are doing is we are basically taking the object itself.
So when we talk about this self here, so if you see the name defining a particular method I'm putting
in this self here, what does this mean?
This means that I am trying to put in the object inside this.
So I'm telling the method that, okay, this is the object which I am talking about, and you need to
work on the attributes which are associated with this particular object.
So this will actually help the internal.
Okay.
This is the object which I need to work on now, whatever I have.
So if I have some bried, which I'm talking about, the GM talking about, this breed is actually belonging
to the object, which I am being called for.
So when I'm seeing Don Dog Breed or us, let's say assembled printer, so here the standard print of
this printed function, this printer method actually gets to know that the object which it needs to
work on is actually some.
So whatever attribute is related to some that is, let's say here it's Labbe.
So this means that this printer needs to work with the attribute which is associated with some which
could be the Labrador or any other details, maybe the name of the dog, the breed of the dog, how
the dog barks with the image of the dog, almost anything which is associated with the dog.
The function will work on that particular thing because it has been called on the object itself.
So now you understand why we actually put in the self here.
If we want to put this self, the function would this method will not get to know that.
What am I supposed to walk upon which I attribute?
Am I supposed to work upon.
So it works on the self, not any other attribute which it has.
So it will get to know that, OK, if I am talking about X object then the name of X object.
They need to work on the edge of this X object to work.
OK.
So let's get for the and let's call it something so that you get a better understanding of it.
So now what we will be doing is let us create something.
Didn't.
Now, let me create a class.
I named this class as so good, so this is my so-called class now.
This class will contain by which is a constant value right now.
The value of PI does not change based on the object.
No matter which circle I'm creating, the value of by will still remain the same.
So that is why I'll give it the value outside the method.
OK, now we will be creating the circle.
So whenever I'm creating the circle, I need to provide the radius to put it OK.
Unless we provide the radius, this will be cannot be created.
So I'm creating a diff for init function, so I'm initializing.
So this is the sensation of the circle.
So I am doing it with self because Salafism is a military.
Then I put in the radius and I give some default value to the circle.
So let's see if my user does not provide any value to the circle.
If the user is not providing any radius, then my program will actually throw an error.
I don't want that to happen, so I'll give it the default value to say one.
And furthermore, I have to
now I will instantiate the value choice itself.
The radius is equal to radius.
So this means that I'm giving the value of this particular value, whatever the user is providing to
self-taught radius.
And in case the user does not provide anything, then it takes one by default.
Next, what I do is I say self taught area is equal to radius into radius in two.
So good not.
So when I say the so-called outby so it understands that whatever value is associated with my class
Sokal, I want to access that particular value.
So I'll go ahead and I will define my next function.
So next function is separate.
So I'm trying to set the radius or else is it radius?
And I live within self again because it is a military thing and I have seen you underscore already and
I go for two and I say self thought radius is equal to you radius.
So what I'm doing is when I when the user will be calling said radius, the user will provide the new
radius.
So with the new radius I will put the value of new radius in the radius which is belonging to that particular
object that I am being supported.
It is right next to it to set up the area.
So what will be the area.
Area would be radius square in two.
But I it it's so it's basically by our square.
So I would say.
New radios into a new year and do so don't buy or Wiggins's self-taught, buy one and the same thing.
No difference you would have written.
Self-taught radio is also here, then that would also have not made any difference.
Just one in the same thing.
Next, I'll create a method defined, so confident.
So I get the
parents and I put myself here because I don't need to provide anything for that.
I use the existing values.
So I was just written
self-taught shadiest and two self-taught by.
In doing so, basically, Dubai are is so confident they so this is what we have next, what we will
do is we will create a surplus.
So let's say my circle is see, I'm creating it.
I'm just creating an object of it.
So I didn't say so.
And I do this.
So once I do this now, so go for this circle.
I'm not giving any argument.
So it does by default, consider that it is equal to one right now.
Let me bring my friend
radius.
So radius is
C dot
radius.
Radius is not radius.
So basically I'm using the object to call the attribute.
Next I need to do the same for area and circumference.
So I would say
area is C area
and.
S c dot.
Now, I need to call this function to get the circumference right.
So I'll just get this from you and I will run this.
So when I run this, I want to get the details accordingly.
Right.
So here I have it.
So the radius comes out to be one area comes to me, three point one for circumference comes out to
be six point to it.
So here what we have done is we have created the instantiation function.
This method will actually allow us to instantiate once this particular command is run.
So once we run this, this will run by default.
Then when I get these dot radius reload a.D.A, I can easily get those because these are available and
these are attributes which are belonging to so good.
I can easily get them for the object respectively.
So if I have some other object, let me copy this and I'd just run this full circle with latitude.
OK, I just run this so you can see the values are updated and I've got the new ones now again let me
do this and make it as easy to OK and let me create this.
I see one.
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
again.
So I think this is even not area.
So you see the value still exists.
It has not been over.
Just don't.
Right now is you can see it to see one has this particular area.
And same thing comes out here, right?
So this is how we will be walking with these now in this anonymity here in order to calculate the area
to be we we to go so blue dot by now we have done this upload by now.
This is because the object does not yet have its own dot by active route.
OK, because right now it has not been created.
OK, once we create this once object of the circle has been created, then this attribute will come
individual.
Right.
So we call this class object attribute fire instead.
OK, so we are using this class attribute.
OK, now in the set radius method, we will be working with an existing Sopel object.
Right.
So when we work on this one, we are already working with an existing Sobol object.
We have the SILVERGLATE.
So this is the reason why.
Now here what happens is now we actually have a fire attribute already existing for this particular
class, this object.
But I'm using FF7 now.
This favella will be existing, but for the very first time when I'm not creating any object at that
time, the circle object is not present because of the classes when it and that is the reason why I'm
using.
So I'm here and I'm using Selldorff by.
Fine here, you could have you so called out by also, but here, if you will be using said goodbye,
it won't work.
OK, OK, so let us see if we change the radius so you can see when we change the radius, things come
out fine.
So here you would have understood that how we use the cell operator.
Right.
So now let's go ahead with the inheritance.
So we will be learning about inheritance in the next session.
Thank you.