1
00:00:00,390 --> 00:00:07,110
Hi, dear friends who are in this lesson, we will learn the overriding and overloading methods in OLP.

2
00:00:07,680 --> 00:00:09,090
So let's give it a go.

3
00:00:11,040 --> 00:00:14,640
And this is what we've learned so far about object oriented programming.

4
00:00:15,140 --> 00:00:21,570
And I will share with you what we have learned in this table in every lesson until the end of our topic.

5
00:00:22,680 --> 00:00:23,970
So have a look at that end.

6
00:00:24,210 --> 00:00:25,320
Let's continue our lesson.

7
00:00:27,840 --> 00:00:34,770
So in Python, if we decide to redefine the methods that we inherit in our class with the same name,

8
00:00:35,370 --> 00:00:38,430
then the method we created will work.

9
00:00:38,640 --> 00:00:39,030
Right?

10
00:00:39,270 --> 00:00:41,820
Not the inherited method makes sense.

11
00:00:42,450 --> 00:00:47,040
So this is called the override method in OLP.

12
00:00:47,880 --> 00:00:51,330
So we can always override the parent class methods.

13
00:00:52,530 --> 00:00:57,690
Also, we can define methods and function specific to our subclasses at any time.

14
00:00:58,530 --> 00:01:04,530
For example, instead of using the init method of the teacher class, we can override the init method

15
00:01:04,860 --> 00:01:06,480
in head master class.

16
00:01:07,410 --> 00:01:07,740
OK.

17
00:01:07,890 --> 00:01:11,760
So in this way, we can add extra attributes to the head master class.

18
00:01:13,110 --> 00:01:15,360
So let's do it and you'll see what I mean.

19
00:01:16,610 --> 00:01:17,200
Class.

20
00:01:17,630 --> 00:01:18,470
Headmaster.

21
00:01:19,520 --> 00:01:20,060
Teacher.

22
00:01:22,870 --> 00:01:23,290
In it.

23
00:01:25,070 --> 00:01:25,540
Self.

24
00:01:25,640 --> 00:01:28,340
Name, surname, profession.

25
00:01:29,260 --> 00:01:29,890
Classes.

26
00:01:31,430 --> 00:01:33,380
Gender, birth date.

27
00:01:34,970 --> 00:01:40,040
So now we define a new attribute named ADD event to the head master class.

28
00:01:40,580 --> 00:01:48,260
So this attribute specifies whether it is authorized to add activity and it'll get true or false.

29
00:01:48,980 --> 00:01:50,960
Self-taught name equals name.

30
00:01:51,740 --> 00:01:54,500
Self-taught surname equals surname.

31
00:02:04,910 --> 00:02:07,100
Self-doubt and event.

32
00:02:09,780 --> 00:02:11,040
Equals at event.

33
00:02:13,050 --> 00:02:14,520
Deaf change class.

34
00:02:16,600 --> 00:02:18,340
Self new class.

35
00:02:19,810 --> 00:02:20,230
Print.

36
00:02:22,670 --> 00:02:23,930
Changing class.

37
00:02:26,620 --> 00:02:30,160
Self taught classes equals new class.

38
00:02:31,120 --> 00:02:35,860
Now in this code runs the head master class init function will override.

39
00:02:37,360 --> 00:02:41,770
So let's create an object named headmaster three headmaster three.

40
00:02:42,400 --> 00:02:44,320
Headmaster William.

41
00:02:45,390 --> 00:02:45,900
Dough.

42
00:02:47,250 --> 00:02:48,030
Headmaster.

43
00:02:49,150 --> 00:02:49,690
None.

44
00:02:50,410 --> 00:02:55,630
Male zero nine zero nine one nine seven zero.

45
00:02:55,960 --> 00:02:56,390
True.

46
00:02:58,400 --> 00:03:00,400
Let's override the show info method.

47
00:03:01,600 --> 00:03:04,660
So first, we'll look at the content of the teacher class.

48
00:03:06,430 --> 00:03:08,420
Now let's override the head master class.

49
00:03:08,470 --> 00:03:09,400
Show info.

50
00:03:10,720 --> 00:03:12,880
Def show info.

51
00:03:14,190 --> 00:03:14,790
Self.

52
00:03:16,440 --> 00:03:19,500
Print headmaster's information.

53
00:03:32,670 --> 00:03:35,730
This is the attribute we just added at event.

54
00:03:38,240 --> 00:03:39,620
Self-doubt at event.

55
00:03:43,870 --> 00:03:46,180
And at this point, we override it.

56
00:03:50,240 --> 00:03:52,730
Now let's create again the last object.

57
00:03:53,890 --> 00:03:57,700
And check the info, headmaster three Dot.

58
00:03:59,970 --> 00:04:00,810
Show info.

59
00:04:02,860 --> 00:04:06,310
And that's if we successfully completed the overwriting process.

60
00:04:07,360 --> 00:04:08,440
How cool is that?

61
00:04:09,940 --> 00:04:12,250
So now let's talk about overloading.

62
00:04:13,330 --> 00:04:21,430
So these methods in OPIS are the methods that are not specifically called by us, but they do belong

63
00:04:21,430 --> 00:04:22,810
to every class.

64
00:04:23,320 --> 00:04:25,840
So most of them are defined by python by default.

65
00:04:25,870 --> 00:04:31,510
Even if we don't define them, however, we do need to define some of these methods specifically.

66
00:04:32,020 --> 00:04:36,000
And the init method, we've seen that before.

67
00:04:36,010 --> 00:04:41,680
Remember, that's an example of these methods that we have to define ourselves.

68
00:04:42,310 --> 00:04:46,030
So what we'll do here is we'll try to learn how to define these methods.

69
00:04:46,450 --> 00:04:50,140
So first will define a new class named car.

70
00:04:50,410 --> 00:04:54,340
And don't let's give an attribute class car.

71
00:05:03,710 --> 00:05:06,200
So now is create an object named car one.

72
00:05:07,290 --> 00:05:08,520
Equals car.

73
00:05:11,270 --> 00:05:17,750
Now, again, examine the overloading methods one by one with the help of our car class.

74
00:05:19,130 --> 00:05:26,960
For example, if we define the init function by ourselves and our own init function, we'll work class

75
00:05:26,960 --> 00:05:27,560
car.

76
00:05:31,140 --> 00:05:32,100
Death in it.

77
00:05:34,210 --> 00:05:38,530
Self brand model, fuel color.

78
00:05:39,600 --> 00:05:40,140
Yea.

79
00:05:42,060 --> 00:05:42,900
Transmission.

80
00:05:47,030 --> 00:05:49,910
Print creating car object.

81
00:05:53,470 --> 00:06:03,070
Self-taught brand equals brand, self-taught model equals model, self-taught fuel equals fuel, self-taught

82
00:06:03,070 --> 00:06:08,230
color equals color, self-taught year equals year.

83
00:06:10,090 --> 00:06:13,540
Self-taught transmission equals transmission.

84
00:06:16,040 --> 00:06:18,950
Now we can create a car object with attributes.

85
00:06:19,790 --> 00:06:23,530
Car two equals car.

86
00:06:24,080 --> 00:06:25,430
Alfa Romeo.

87
00:06:26,240 --> 00:06:26,930
Julia.

88
00:06:30,120 --> 00:06:30,720
Petrol.

89
00:06:31,760 --> 00:06:32,330
Red.

90
00:06:33,930 --> 00:06:35,370
Twenty seventeen.

91
00:06:36,800 --> 00:06:37,550
Manual.

92
00:06:39,260 --> 00:06:43,640
And normally when you use a print function print.

93
00:06:45,060 --> 00:06:46,050
Car to.

94
00:06:47,750 --> 00:06:58,010
Python returns to us this, however, if we define the SDR or string method ourselves, we will now

95
00:06:58,010 --> 00:07:01,580
be able to write the contents of the car more clearly on the screen.

96
00:07:02,210 --> 00:07:04,670
So come on, let me show you Def.

97
00:07:05,990 --> 00:07:06,230
As.

98
00:07:08,950 --> 00:07:09,580
Self.

99
00:07:12,600 --> 00:07:15,690
Now I'm going to use one of the editorial methods in Python.

100
00:07:15,780 --> 00:07:18,250
If you want, you can research that on the Internet.

101
00:07:18,270 --> 00:07:22,800
It's more than not worth it to go into it here, but just watch what I do.

102
00:07:24,070 --> 00:07:26,110
Return model.

103
00:07:27,400 --> 00:07:28,240
And brand.

104
00:07:33,690 --> 00:07:34,560
And fuel.

105
00:07:38,720 --> 00:07:39,710
And color.

106
00:07:44,630 --> 00:07:45,500
And year.

107
00:07:52,460 --> 00:07:53,690
And transmission.

108
00:07:59,420 --> 00:08:00,380
That format.

109
00:08:06,000 --> 00:08:07,260
Self-taught brand.

110
00:08:08,950 --> 00:08:09,730
Doubt fuel.

111
00:08:11,590 --> 00:08:12,700
Self-taught color.

112
00:08:17,690 --> 00:08:18,440
Self-taught.

113
00:08:18,470 --> 00:08:19,100
Yea.

114
00:08:20,560 --> 00:08:22,090
Self-taught transmission.

115
00:08:28,190 --> 00:08:34,070
Now we'll try to create our object again and printed print card, too.

116
00:08:35,360 --> 00:08:36,350
And there you go.

117
00:08:36,350 --> 00:08:37,250
It's a working well.

118
00:08:40,520 --> 00:08:46,550
Now, the Dell method is the method that is executed when we delete an object in Python with a key word

119
00:08:46,670 --> 00:08:47,270
Dell.

120
00:08:48,290 --> 00:08:53,300
Also, we can add extra features by defining this method ourselves.

121
00:08:54,440 --> 00:08:55,760
So let's go ahead and do it.

122
00:08:56,870 --> 00:08:57,770
So now let's define it.

123
00:08:59,040 --> 00:08:59,610
Self.

124
00:09:02,060 --> 00:09:02,540
Print.

125
00:09:05,270 --> 00:09:07,460
The leading car object.

126
00:09:15,620 --> 00:09:19,730
And let's define another object named Car three.

127
00:09:23,470 --> 00:09:29,050
Bentley, Brooklands, Petrel, Black, 1997 Automattic.

128
00:09:41,050 --> 00:09:43,180
And now let's check the info.

129
00:09:52,010 --> 00:09:53,630
So now let's delete the object.

130
00:09:58,740 --> 00:10:02,400
We deleted our object, cool, so let's control it.

131
00:10:03,510 --> 00:10:06,090
It's actually, you know, we can see if it's deleted or not.

132
00:10:06,900 --> 00:10:08,430
So print cr3.

133
00:10:14,360 --> 00:10:14,970
And that's it.

134
00:10:14,990 --> 00:10:16,280
We can tell our methods working.

135
00:10:18,050 --> 00:10:18,500
Cool.

136
00:10:18,530 --> 00:10:23,840
So in this lesson, we have learned the concept of override and overload in Python.

137
00:10:24,260 --> 00:10:29,660
So with these concepts, the inheritance in object oriented programming is complete.

138
00:10:30,560 --> 00:10:31,010
Cool.

139
00:10:31,310 --> 00:10:31,580
See you.

140
00:10:31,580 --> 00:10:32,240
Next lesson.

141
00:10:32,270 --> 00:10:33,050
Have a nice day.
