WEBVTT

00:00.570 --> 00:05.850
Next set of questions is regarding object oriented programming.

00:06.450 --> 00:13.170
So let's have a look at the questions and we will be solving these one by one.

00:14.220 --> 00:18.720
So the first question is create a world class with max speed.

00:19.080 --> 00:21.480
And my login starts after that.

00:23.340 --> 00:26.010
So let's pause the video.

00:26.340 --> 00:31.620
And you can create this class and you can enforce Luder to see the solution.

00:33.780 --> 00:35.890
Now, let's look at the solution for the scene.

00:35.910 --> 00:43.860
So to create A Class B, C, class and class name is set to be very carefully selected.

00:49.110 --> 00:51.540
Each class will have ultimate function.

00:51.930 --> 00:54.270
So we will define the function.

01:01.870 --> 01:11.710
And in that function takes skill and the attributes which you've suggesting, Max, speed and mileage,

01:17.110 --> 01:25.900
and it's like the function novins we have created these two instances, we need to initialize the scene.

01:26.410 --> 01:28.460
So we really do the scene by scene.

01:29.050 --> 01:37.360
So this is equal to max speed

01:50.920 --> 01:52.060
is equal to mileage.

01:55.830 --> 02:06.510
Now, once we have created this class, we can run this so we can see let's create the vehicle, so

02:06.510 --> 02:08.610
let's see one.

02:10.080 --> 02:24.180
And this will be something that speaks to one thing and my beach as well.

02:26.010 --> 02:29.910
So let's bring the actor will

02:32.760 --> 02:41.940
say one stop max speed ba, more than

02:47.490 --> 02:48.810
150 and 20.

02:49.230 --> 03:01.020
You can also look at the different attributes or you can simply say, let's say we can see hell and

03:01.020 --> 03:03.780
we can see wrinkles.

03:05.490 --> 03:16.620
And here you can see that it has these two attributes, max speed and mileage, which have been defined.

03:21.300 --> 03:25.230
Next is another question which we will be solving.

03:29.060 --> 03:34.220
So the next question is to create a good class without any variable in.

03:35.090 --> 03:38.140
So this has to be a completely blank class.

03:38.570 --> 03:44.330
So drydock was the question and try this and pose for the solution.

03:49.820 --> 03:58.760
So let's look at this solution for this so we can simply create a class with nothing in it by simply

03:58.760 --> 04:01.070
giving the class name

04:04.460 --> 04:10.220
and saying that this would create create an empty class with nothing and say this.

04:10.280 --> 04:21.650
If I run this and let's see as they help, they can you can see that it does not contain evil and make

04:21.650 --> 04:22.310
the plight of one.

04:26.420 --> 04:28.260
Let's look at the next question.

04:28.280 --> 04:35.690
So the next question is to create a giant class bus that will inherit all the variables and methods

04:35.690 --> 04:36.860
of the legal class.

04:37.370 --> 04:40.440
So this is a legal class which they have already provided.

04:40.940 --> 04:48.380
The wealthy class canceled campaigns of the weekly maximum speed mileage, and it has been initiated,

04:48.380 --> 04:49.700
initialized accordingly.

04:50.000 --> 04:58.580
So we want to create a giant class, which is bus object, and it will inherit all the variables.

05:00.560 --> 05:04.610
You can pause the video and later you can unfold for the solution.

05:15.820 --> 05:19.340
Let's solve this problem now to solve to solve this problem.

05:19.360 --> 05:29.140
We can simply create class, but which should inherit all the properties of the burning glassmaking.

05:29.140 --> 05:31.360
So we will pass Boston vehicle and save this.

05:32.740 --> 05:37.930
And instead of this, we will define

05:43.570 --> 05:45.520
initialised with says.

05:46.900 --> 05:48.250
I didn't say that.

05:48.250 --> 05:53.770
We need to give your name my speed mileage

05:58.450 --> 05:59.830
and these.

06:17.920 --> 06:25.540
So this has already been created, named as has been given, so we just need to create waker.

06:25.550 --> 06:28.420
So instead of doing this, we will simply say fast.

06:30.160 --> 06:34.890
And when we run this level, do we create more technical class for creating the object?

06:34.900 --> 06:37.330
We can simply say, oh, that's cool.

06:37.330 --> 06:37.780
That's

06:41.200 --> 06:43.570
an inside this thinking of the object.

06:43.570 --> 06:49.180
And the object will take all these parameters the way the other one thinks.

06:49.540 --> 06:51.760
So we can simply give the name bot.

06:52.420 --> 06:55.180
So they want the name to be fully Valvo.

06:55.180 --> 06:56.530
So we give the same.

06:59.320 --> 07:04.510
Then it needs to have the speed as quantity and mileage as well.

07:05.290 --> 07:12.100
So after that, we can bring the in this particular manner.

07:12.100 --> 07:16.000
We need the printing building so we can simply say print.

07:18.470 --> 07:20.730
And we can give the schools

07:23.560 --> 07:24.020
problem.

07:24.460 --> 07:34.810
Instead of school, we need to get the school bus dock the name.

07:37.000 --> 07:39.820
Then we need speed.

07:44.410 --> 07:49.300
Then we need school bus start, max speed.

07:49.390 --> 07:58.050
So you can see we are getting like the name schools, Volvo, speed, Aswani and Minor just with assemblies.

07:59.710 --> 08:01.870
Now, let's go to the next question.

08:04.450 --> 08:07.620
So here we want to play in.

08:08.860 --> 08:16.480
So we already have created the class where you can hear the glasspiegel again has all the attributes

08:16.480 --> 08:18.970
name must be milage wanted to present day.

08:19.510 --> 08:30.710
And inside this, we want to have a capacity argument of bus seeping capacity and a default value of

08:31.060 --> 08:32.230
needs to be given to it.

08:33.490 --> 08:39.700
Further, we want to use these present code for Lenegan plus.

08:40.210 --> 08:46.630
And we need to apply method overrating to get the required output.

08:46.930 --> 08:50.860
The output should be that the seating capacity of the bus is the passenger.

08:51.160 --> 08:59.170
So all we need to do is we need to use the Bible class to create the child class bus.

08:59.410 --> 09:04.150
And the Zeigler's bus should have a default capacity of 50.

09:05.350 --> 09:07.130
And it should use the same.

09:08.620 --> 09:16.290
So you can pause the video as I tried out and you can unfold for viewing this olution.

09:17.350 --> 09:21.040
We have the vehicle class already present.

09:22.780 --> 09:31.270
For that, we need to create the giant last bus so we can see class and we can see a bus and the way

09:31.270 --> 09:36.100
Colleville bus will in headed Wakool Solis's vehicle.

09:36.670 --> 09:40.170
And we will define the function again.

09:40.180 --> 09:44.900
Now, once we inherited Riegle, this function already is present.

09:45.460 --> 09:55.150
So you can simply take that or let's see bus and you can check this by taking help on the bus.

09:57.360 --> 10:01.000
See, these are already present.

10:01.360 --> 10:03.310
The method is already present.

10:03.970 --> 10:05.710
But we need to override it.

10:05.950 --> 10:06.290
Right.

10:06.310 --> 10:12.430
We need to apply method overrating and we need to change the seating capacity and to have the full value

10:12.430 --> 10:12.890
of the speech.

10:12.910 --> 10:17.890
So what we can do is we can simply create the function of seating capacity again.

10:21.610 --> 10:26.320
And we need to change it so that the capacity will have a default value of coffee.

10:26.320 --> 10:31.330
So we can basically do that by assigning it as the value of P and.

10:33.720 --> 10:36.450
You can simply return the value.

10:36.870 --> 10:43.710
Now, here, we need to return the value as in a different way.

10:43.980 --> 10:46.170
So let's get rid of this.

10:50.430 --> 10:52.410
So here we will see silver

10:56.250 --> 10:59.550
dot seating

11:02.160 --> 11:03.090
capacity.

11:07.020 --> 11:07.920
Capacity

11:13.320 --> 11:14.850
is equal to 50.

11:15.210 --> 11:23.610
So all we are doing here is we are giving our default value to our bid class here.

11:24.090 --> 11:26.010
So let's run this again.

11:27.960 --> 11:35.490
So here you can see that the method has seating capacity as a fee on the inherited matter.

11:35.970 --> 11:40.380
Has this in it as an inherited one.

11:41.820 --> 11:42.570
Let's go forward.

11:43.680 --> 11:46.280
Now we need to get the output here.

11:46.290 --> 11:48.480
So let's see how it is helping out.

11:48.480 --> 11:50.930
So let's create the bus.

11:51.240 --> 11:53.220
Simply we create the bus again.

11:55.920 --> 11:58.050
So we are creating the school bus again.

11:58.330 --> 12:00.090
Volvo 188 will.

12:00.780 --> 12:02.280
And let's simply spring

12:05.940 --> 12:12.120
school bus docked seating

12:15.420 --> 12:16.260
capacity

12:20.910 --> 12:21.920
and let's run this.

12:22.890 --> 12:27.780
So now here you can see that this heating capacity of the school, Volvo, is 250 passengers.

12:28.170 --> 12:35.280
So it has simply over been this capacity to the bedroom plus.

12:36.810 --> 12:39.570
So for depen class, it does bloodedness.

12:40.080 --> 12:42.480
Let's see what will happen if we do not.

12:44.700 --> 12:47.480
Let's just try and get a seat.

12:48.990 --> 12:52.800
It is missing one required positionally argument capacity.

12:53.370 --> 12:54.570
Let's do this.

12:56.400 --> 12:57.420
Let's do this.

13:00.930 --> 13:04.440
And you can see seating capacity of the school hallways for passengers.

13:05.880 --> 13:08.580
So you can do it any way you want.

13:09.180 --> 13:13.590
This is the standard way of overriding metal overrating.

13:15.210 --> 13:19.320
Now, let's go ahead and try to solve another problem.

13:23.210 --> 13:25.760
OK, so this is the problem.

13:29.180 --> 13:37.640
So here we need to define property that should have the same value for every last instance.

13:38.960 --> 13:42.380
Define a class attribute value over the default value.

13:42.380 --> 13:43.070
That is right.

13:43.490 --> 13:47.900
Every this should be like use the following code for this exercise.

13:47.930 --> 13:52.460
So we have created a molecule which will have me my speed mileage.

13:52.850 --> 13:55.520
And then there will be bus God.

13:55.760 --> 13:58.100
You can create these giant clusters.

13:58.400 --> 14:06.650
And we need to modify these methods such that the default color will be white for all of these.

14:08.330 --> 14:09.590
So you can try this out.

14:10.100 --> 14:15.170
And don't forget to try this first and then only look at the solution.

14:15.680 --> 14:16.430
Try this out.

14:16.430 --> 14:19.700
Voiced pause, this video and on pause for solution.

14:26.720 --> 14:31.370
Now let's have a look and the solution for this particular problem.

14:33.770 --> 14:39.050
We have already created class vehicle bus and got here.

14:40.050 --> 14:48.830
Now the variables which are created in in it, these are called the instance variables and instant variables.

14:48.830 --> 14:51.950
Value is specific to a particular instance of the class.

14:52.280 --> 14:54.890
So let's say I click, create an instance.

14:55.940 --> 14:57.050
Let's say fl1.

14:57.830 --> 15:00.240
Then I create another instance or defeat.

15:00.650 --> 15:05.030
So the preview for this will be constant.

15:05.300 --> 15:08.990
So whatever attribute instance variable I will be creating.

15:09.320 --> 15:15.710
It will be specific to that only for that particular object of the class instead.

15:16.910 --> 15:21.860
But for example, in the solution, all we object have named max speed mileage.

15:22.220 --> 15:25.610
So all of these will have different values for different objects.

15:26.360 --> 15:27.530
But there are different.

15:27.650 --> 15:30.110
There is another thing which is called class attribute.

15:30.440 --> 15:35.840
Now, class attribute is something which will have same value for all the class instance.

15:36.170 --> 15:43.820
So, for example, if we want to create a particular value color, which would be common for all the

15:44.090 --> 15:49.520
objects which are created out of this, then that is called an attribute.

15:49.940 --> 15:50.270
OK.

15:50.480 --> 15:52.970
So there will be a same value.

15:53.270 --> 15:56.840
That is it will have same value for every class instance.

15:56.840 --> 15:58.550
That is, it will be an actor to build.

15:59.000 --> 15:59.720
And if

16:02.540 --> 16:05.120
it does not have, then it reveal variable itself.

16:05.810 --> 16:09.710
So let's create a class attribute.

16:10.130 --> 16:14.510
So for creating the class attribute, let's copy this all again.

16:15.890 --> 16:18.410
So we will need to modify this particular one.

16:18.680 --> 16:19.910
So how do we modify it?

16:19.910 --> 16:27.200
We will make the class attribute and fulfilling the class attribute we declared inside the class itself

16:27.200 --> 16:28.210
before the init.

16:29.120 --> 16:32.780
So we can simply say Kalush

16:35.900 --> 16:43.730
is equal to right and everything else remains the same.

16:44.270 --> 16:54.230
So when I run this, what happens is I can create another object of it.

16:54.740 --> 16:58.630
So let's create object from here to a

17:03.890 --> 17:06.020
school bus with this detail.

17:08.480 --> 17:12.140
And let's create a car also.

17:21.850 --> 17:22.670
The chips.

17:35.940 --> 17:36.600
Like this.

17:37.230 --> 17:45.450
Now let's try to get different attributes out of it so we can simply get the attribute by saying

17:53.040 --> 17:56.520
spin school bus dot.

18:04.630 --> 18:05.200
Colors,

18:15.770 --> 18:18.720
schools, start me

18:22.600 --> 18:31.390
and do this for the goggles, the same time, you're also going to fly.

18:32.050 --> 18:32.800
That's from this.

18:33.220 --> 18:41.950
So you can see that the guy's name is already Q five and the color is shown as white and so on.

18:42.190 --> 18:45.040
So this is how you can get all of the attributes also.

18:45.040 --> 18:47.290
I mean, not favorable for you.

18:47.620 --> 18:51.850
You can modify this index to go get all the values.

18:52.490 --> 18:58.210
Just remember, if you want to have attributes which would be common to all the instances which would

18:58.210 --> 19:04.690
be shared by all the instances, then it should be defined like this.

19:08.260 --> 19:11.350
Let's go ahead and solve the next problem.

19:13.510 --> 19:15.850
So this is, again, an inheritance problem.

19:16.300 --> 19:26.200
So here we want to create a bus child class, and the default surcharge of any vehicle is seating capacity,

19:26.710 --> 19:29.950
which needs to be Endou multiplied by 100.

19:30.160 --> 19:35.140
So default surcharge for the vehicle is seating capacity in 200.

19:35.470 --> 19:42.310
If the vehicle is a bus, then we need to add an extra 10 percent on the full fare

19:47.020 --> 19:48.490
as a maintainance charge.

19:48.490 --> 19:55.270
So that order fare for bus instance, will be Fullam final amount is equal due to a bit of that in Lotame,

19:55.270 --> 19:55.990
times double will.

19:56.410 --> 20:02.440
So basically capacity in two hundred plus 10 percent of the total fare, which has been calculated.

20:03.520 --> 20:06.400
Now the bus seating capacity is Fofi.

20:06.580 --> 20:09.250
So the final set amount should be fifty five hundred.

20:09.520 --> 20:13.240
You need to override the third method of a legal class in bus.

20:13.870 --> 20:15.580
Use the following code for the seat.

20:16.090 --> 20:20.080
We need to access the bed and blast from inside the method of the class.

20:20.440 --> 20:22.480
So this is what we already have.

20:22.780 --> 20:26.980
So we have the winkel class, which has me milage capacity.

20:26.990 --> 20:31.840
Then we have set, which is calculated by standard capacity in 200.

20:32.170 --> 20:35.290
Then we have the bus vehicle for the bus vehicle.

20:35.590 --> 20:42.070
We need to calculate the Fed by multiplying the capacity in all the capacity has to be 50.

20:42.400 --> 20:47.040
So according to that, it should be solved accordingly.

20:47.050 --> 20:50.260
So you can solve it like this.

20:50.410 --> 20:52.570
This is having a value for fee.

20:52.570 --> 20:54.730
You can give a deferred wiliest for Feltl.

20:55.210 --> 20:58.660
So Trino try to solve this problem.

20:59.440 --> 21:03.220
And you can always pause and try.

21:03.220 --> 21:06.550
And then I'm forced to view the solution for that.

21:06.910 --> 21:08.560
But please give it a try.

21:09.580 --> 21:11.870
So let's solve this problem now.

21:12.790 --> 21:16.360
So Ford's solution of this problem, we can use this board itself.

21:18.040 --> 21:21.820
Now, here, we need to modify the function first.

21:22.270 --> 21:28.570
So in the bus, Wakool, we need to modify this Fed function.

21:28.900 --> 21:34.900
So here in sort of bus, we will define Fed and inserts it.

21:35.310 --> 21:45.400
Now, the amount which will be amount will be equal to Super Nafez.

21:52.210 --> 21:55.380
And on top of it, this is what is common to all.

21:56.800 --> 22:04.720
And on top of this, the amount is equal to among last

22:08.680 --> 22:14.170
amount to 10 percent.

22:14.680 --> 22:17.460
Ten percent is equal to zero point one.

22:17.470 --> 22:18.580
So you can meet that goal.

22:18.600 --> 22:20.080
So it is completely up to you.

22:20.440 --> 22:24.430
So as you say, zero point one here for simplicity.

22:25.060 --> 22:30.040
And we can just put it into the brackets.

22:32.950 --> 22:36.030
And begin the Dondi amount.

22:39.670 --> 22:46.210
So it gets to the base, Ferus 55 and so that's it.

22:46.810 --> 22:50.260
Now let's have a look at the next problem.

22:54.130 --> 22:59.400
Now here we have the domain which glass are given but object belongs to.

22:59.740 --> 23:02.470
So we simply need to check the type of an object.

23:02.920 --> 23:05.830
So we have this class vehicle here.

23:06.370 --> 23:11.310
It has the definition as this class bus and the various classes vehicle.

23:12.340 --> 23:16.110
So we have created an instance of bus.

23:18.280 --> 23:24.010
So you just need to find out the class of the object.

23:24.610 --> 23:27.460
So it is a simple one, Distrito.

23:30.340 --> 23:32.830
You can pause and unpause for the solution.

23:38.970 --> 23:44.190
So let's look at this olution, so for checking the glass, you can simply check the type.

23:45.120 --> 23:51.900
So for checking the baby, you can simply say stay on the instance name.

24:02.930 --> 24:09.830
So you can see that this is the instance of the object of the blasphemous.

24:12.260 --> 24:18.530
Similarly, if you would have checked for any instance which had been created using liCl, then for

24:18.550 --> 24:21.620
Dagley object, they would have been a plague.

24:22.910 --> 24:24.140
So this was a simple one.

24:24.770 --> 24:29.840
Let's go ahead and have a look at for the next questions.

24:33.320 --> 24:38.930
So here we need to determine if a school bus is also an instance of the recent floods.

24:39.470 --> 24:43.700
So we did check that school, which has an instance of bus.

24:44.030 --> 24:47.440
So we need to verify if it is an instance of the working class soldiers.

24:47.440 --> 24:50.030
So everything is just the same.

24:50.540 --> 24:58.670
Let's have a look at the data and you can see if you could squeeze us.

25:02.270 --> 25:09.680
It gives me a bus now because bus is the giant class of people who logically school bus should also

25:09.680 --> 25:12.200
have be an instant a link to the bus.

25:12.200 --> 25:13.430
But we need to verify that.

25:13.850 --> 25:20.870
So just all that you can try different functions with, of anything and see if you are able to find

25:20.870 --> 25:21.350
something.

25:21.740 --> 25:26.210
And you can try help to find out if you have any function like that.

25:28.520 --> 25:31.130
You can pause on bus for the solution.

25:36.430 --> 25:38.860
So now let's quickly look at the solution.

25:41.860 --> 25:49.150
Now, instead of baby, let's look at if it starts

25:52.030 --> 25:55.030
to reverse for my baby

25:58.630 --> 26:01.290
and one this so you can see it gives back to.

26:02.500 --> 26:10.810
So this is a function that you can basically use on an object and a glass to verify if an object is

26:11.170 --> 26:14.320
an instance of a particular glass of milk.

26:19.380 --> 26:23.550
So that's it for this type of object oriented programming questions.
