Next set of questions is regarding object oriented programming.
So let's have a look at the questions and we will be solving these one by one.
So the first question is create a world class with max speed.
And my login starts after that.
So let's pause the video.
And you can create this class and you can enforce Luder to see the solution.
Now, let's look at the solution for the scene.
So to create A Class B, C, class and class name is set to be very carefully selected.
Each class will have ultimate function.
So we will define the function.
And in that function takes skill and the attributes which you've suggesting, Max, speed and mileage,
and it's like the function novins we have created these two instances, we need to initialize the scene.
So we really do the scene by scene.
So this is equal to max speed
is equal to mileage.
Now, once we have created this class, we can run this so we can see let's create the vehicle, so
let's see one.
And this will be something that speaks to one thing and my beach as well.
So let's bring the actor will
say one stop max speed ba, more than
150 and 20.
You can also look at the different attributes or you can simply say, let's say we can see hell and
we can see wrinkles.
And here you can see that it has these two attributes, max speed and mileage, which have been defined.
Next is another question which we will be solving.
So the next question is to create a good class without any variable in.
So this has to be a completely blank class.
So drydock was the question and try this and pose for the solution.
So let's look at this solution for this so we can simply create a class with nothing in it by simply
giving the class name
and saying that this would create create an empty class with nothing and say this.
If I run this and let's see as they help, they can you can see that it does not contain evil and make
the plight of one.
Let's look at the next question.
So the next question is to create a giant class bus that will inherit all the variables and methods
of the legal class.
So this is a legal class which they have already provided.
The wealthy class canceled campaigns of the weekly maximum speed mileage, and it has been initiated,
initialized accordingly.
So we want to create a giant class, which is bus object, and it will inherit all the variables.
You can pause the video and later you can unfold for the solution.
Let's solve this problem now to solve to solve this problem.
We can simply create class, but which should inherit all the properties of the burning glassmaking.
So we will pass Boston vehicle and save this.
And instead of this, we will define
initialised with says.
I didn't say that.
We need to give your name my speed mileage
and these.
So this has already been created, named as has been given, so we just need to create waker.
So instead of doing this, we will simply say fast.
And when we run this level, do we create more technical class for creating the object?
We can simply say, oh, that's cool.
That's
an inside this thinking of the object.
And the object will take all these parameters the way the other one thinks.
So we can simply give the name bot.
So they want the name to be fully Valvo.
So we give the same.
Then it needs to have the speed as quantity and mileage as well.
So after that, we can bring the in this particular manner.
We need the printing building so we can simply say print.
And we can give the schools
problem.
Instead of school, we need to get the school bus dock the name.
Then we need speed.
Then we need school bus start, max speed.
So you can see we are getting like the name schools, Volvo, speed, Aswani and Minor just with assemblies.
Now, let's go to the next question.
So here we want to play in.
So we already have created the class where you can hear the glasspiegel again has all the attributes
name must be milage wanted to present day.
And inside this, we want to have a capacity argument of bus seeping capacity and a default value of
needs to be given to it.
Further, we want to use these present code for Lenegan plus.
And we need to apply method overrating to get the required output.
The output should be that the seating capacity of the bus is the passenger.
So all we need to do is we need to use the Bible class to create the child class bus.
And the Zeigler's bus should have a default capacity of 50.
And it should use the same.
So you can pause the video as I tried out and you can unfold for viewing this olution.
We have the vehicle class already present.
For that, we need to create the giant last bus so we can see class and we can see a bus and the way
Colleville bus will in headed Wakool Solis's vehicle.
And we will define the function again.
Now, once we inherited Riegle, this function already is present.
So you can simply take that or let's see bus and you can check this by taking help on the bus.
See, these are already present.
The method is already present.
But we need to override it.
Right.
We need to apply method overrating and we need to change the seating capacity and to have the full value
of the speech.
So what we can do is we can simply create the function of seating capacity again.
And we need to change it so that the capacity will have a default value of coffee.
So we can basically do that by assigning it as the value of P and.
You can simply return the value.
Now, here, we need to return the value as in a different way.
So let's get rid of this.
So here we will see silver
dot seating
capacity.
Capacity
is equal to 50.
So all we are doing here is we are giving our default value to our bid class here.
So let's run this again.
So here you can see that the method has seating capacity as a fee on the inherited matter.
Has this in it as an inherited one.
Let's go forward.
Now we need to get the output here.
So let's see how it is helping out.
So let's create the bus.
Simply we create the bus again.
So we are creating the school bus again.
Volvo 188 will.
And let's simply spring
school bus docked seating
capacity
and let's run this.
So now here you can see that this heating capacity of the school, Volvo, is 250 passengers.
So it has simply over been this capacity to the bedroom plus.
So for depen class, it does bloodedness.
Let's see what will happen if we do not.
Let's just try and get a seat.
It is missing one required positionally argument capacity.
Let's do this.
And you can see seating capacity of the school hallways for passengers.
So you can do it any way you want.
This is the standard way of overriding metal overrating.
Now, let's go ahead and try to solve another problem.
OK, so this is the problem.
So here we need to define property that should have the same value for every last instance.
Define a class attribute value over the default value.
That is right.
Every this should be like use the following code for this exercise.
So we have created a molecule which will have me my speed mileage.
And then there will be bus God.
You can create these giant clusters.
And we need to modify these methods such that the default color will be white for all of these.
So you can try this out.
And don't forget to try this first and then only look at the solution.
Try this out.
Voiced pause, this video and on pause for solution.
Now let's have a look and the solution for this particular problem.
We have already created class vehicle bus and got here.
Now the variables which are created in in it, these are called the instance variables and instant variables.
Value is specific to a particular instance of the class.
So let's say I click, create an instance.
Let's say fl1.
Then I create another instance or defeat.
So the preview for this will be constant.
So whatever attribute instance variable I will be creating.
It will be specific to that only for that particular object of the class instead.
But for example, in the solution, all we object have named max speed mileage.
So all of these will have different values for different objects.
But there are different.
There is another thing which is called class attribute.
Now, class attribute is something which will have same value for all the class instance.
So, for example, if we want to create a particular value color, which would be common for all the
objects which are created out of this, then that is called an attribute.
OK.
So there will be a same value.
That is it will have same value for every class instance.
That is, it will be an actor to build.
And if
it does not have, then it reveal variable itself.
So let's create a class attribute.
So for creating the class attribute, let's copy this all again.
So we will need to modify this particular one.
So how do we modify it?
We will make the class attribute and fulfilling the class attribute we declared inside the class itself
before the init.
So we can simply say Kalush
is equal to right and everything else remains the same.
So when I run this, what happens is I can create another object of it.
So let's create object from here to a
school bus with this detail.
And let's create a car also.
The chips.
Like this.
Now let's try to get different attributes out of it so we can simply get the attribute by saying
spin school bus dot.
Colors,
schools, start me
and do this for the goggles, the same time, you're also going to fly.
That's from this.
So you can see that the guy's name is already Q five and the color is shown as white and so on.
So this is how you can get all of the attributes also.
I mean, not favorable for you.
You can modify this index to go get all the values.
Just remember, if you want to have attributes which would be common to all the instances which would
be shared by all the instances, then it should be defined like this.
Let's go ahead and solve the next problem.
So this is, again, an inheritance problem.
So here we want to create a bus child class, and the default surcharge of any vehicle is seating capacity,
which needs to be Endou multiplied by 100.
So default surcharge for the vehicle is seating capacity in 200.
If the vehicle is a bus, then we need to add an extra 10 percent on the full fare
as a maintainance charge.
So that order fare for bus instance, will be Fullam final amount is equal due to a bit of that in Lotame,
times double will.
So basically capacity in two hundred plus 10 percent of the total fare, which has been calculated.
Now the bus seating capacity is Fofi.
So the final set amount should be fifty five hundred.
You need to override the third method of a legal class in bus.
Use the following code for the seat.
We need to access the bed and blast from inside the method of the class.
So this is what we already have.
So we have the winkel class, which has me milage capacity.
Then we have set, which is calculated by standard capacity in 200.
Then we have the bus vehicle for the bus vehicle.
We need to calculate the Fed by multiplying the capacity in all the capacity has to be 50.
So according to that, it should be solved accordingly.
So you can solve it like this.
This is having a value for fee.
You can give a deferred wiliest for Feltl.
So Trino try to solve this problem.
And you can always pause and try.
And then I'm forced to view the solution for that.
But please give it a try.
So let's solve this problem now.
So Ford's solution of this problem, we can use this board itself.
Now, here, we need to modify the function first.
So in the bus, Wakool, we need to modify this Fed function.
So here in sort of bus, we will define Fed and inserts it.
Now, the amount which will be amount will be equal to Super Nafez.
And on top of it, this is what is common to all.
And on top of this, the amount is equal to among last
amount to 10 percent.
Ten percent is equal to zero point one.
So you can meet that goal.
So it is completely up to you.
So as you say, zero point one here for simplicity.
And we can just put it into the brackets.
And begin the Dondi amount.
So it gets to the base, Ferus 55 and so that's it.
Now let's have a look at the next problem.
Now here we have the domain which glass are given but object belongs to.
So we simply need to check the type of an object.
So we have this class vehicle here.
It has the definition as this class bus and the various classes vehicle.
So we have created an instance of bus.
So you just need to find out the class of the object.
So it is a simple one, Distrito.
You can pause and unpause for the solution.
So let's look at this olution, so for checking the glass, you can simply check the type.
So for checking the baby, you can simply say stay on the instance name.
So you can see that this is the instance of the object of the blasphemous.
Similarly, if you would have checked for any instance which had been created using liCl, then for
Dagley object, they would have been a plague.
So this was a simple one.
Let's go ahead and have a look at for the next questions.
So here we need to determine if a school bus is also an instance of the recent floods.
So we did check that school, which has an instance of bus.
So we need to verify if it is an instance of the working class soldiers.
So everything is just the same.
Let's have a look at the data and you can see if you could squeeze us.
It gives me a bus now because bus is the giant class of people who logically school bus should also
have be an instant a link to the bus.
But we need to verify that.
So just all that you can try different functions with, of anything and see if you are able to find
something.
And you can try help to find out if you have any function like that.
You can pause on bus for the solution.
So now let's quickly look at the solution.
Now, instead of baby, let's look at if it starts
to reverse for my baby
and one this so you can see it gives back to.
So this is a function that you can basically use on an object and a glass to verify if an object is
an instance of a particular glass of milk.
So that's it for this type of object oriented programming questions.