Overriding Methods

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€85.25
List Price:  €119.35
You save:  €34.10
£73.65
List Price:  £103.11
You save:  £29.46
CA$137.51
List Price:  CA$192.52
You save:  CA$55.01
A$152.37
List Price:  A$213.33
You save:  A$60.95
S$127.89
List Price:  S$179.06
You save:  S$51.16
HK$784.91
List Price:  HK$1,098.90
You save:  HK$313.99
CHF 80.26
List Price:  CHF 112.36
You save:  CHF 32.10
NOK kr1,017.73
List Price:  NOK kr1,424.87
You save:  NOK kr407.13
DKK kr636.20
List Price:  DKK kr890.70
You save:  DKK kr254.50
NZ$166.79
List Price:  NZ$233.52
You save:  NZ$66.72
د.إ367.25
List Price:  د.إ514.17
You save:  د.إ146.91
৳12,163.14
List Price:  ৳17,028.89
You save:  ৳4,865.74
₹8,742.12
List Price:  ₹12,239.31
You save:  ₹3,497.19
RM420.70
List Price:  RM589
You save:  RM168.30
₦153,434.65
List Price:  ₦214,814.65
You save:  ₦61,380
₨28,388.61
List Price:  ₨39,745.20
You save:  ₨11,356.58
฿3,225.97
List Price:  ฿4,516.49
You save:  ฿1,290.52
₺4,073.49
List Price:  ₺5,703.05
You save:  ₺1,629.55
B$541.56
List Price:  B$758.21
You save:  B$216.64
R1,749.41
List Price:  R2,449.25
You save:  R699.83
Лв166.91
List Price:  Лв233.69
You save:  Лв66.77
₩137,643.97
List Price:  ₩192,707.06
You save:  ₩55,063.09
₪338.44
List Price:  ₪473.83
You save:  ₪135.39
₱5,668.53
List Price:  ₱7,936.17
You save:  ₱2,267.64
¥14,720.52
List Price:  ¥20,609.32
You save:  ¥5,888.80
MX$1,852.79
List Price:  MX$2,593.99
You save:  MX$741.19
QR364.13
List Price:  QR509.80
You save:  QR145.66
P1,346.37
List Price:  P1,884.98
You save:  P538.60
KSh12,918.70
List Price:  KSh18,086.70
You save:  KSh5,168
E£4,832.54
List Price:  E£6,765.75
You save:  E£1,933.21
ብር14,000.37
List Price:  ብር19,601.08
You save:  ብር5,600.70
Kz91,186.38
List Price:  Kz127,664.58
You save:  Kz36,478.20
CLP$95,604.43
List Price:  CLP$133,850.03
You save:  CLP$38,245.60
CN¥717.34
List Price:  CN¥1,004.31
You save:  CN¥286.96
RD$6,134.99
List Price:  RD$8,589.23
You save:  RD$2,454.24
DA12,957.97
List Price:  DA18,141.67
You save:  DA5,183.70
FJ$224.85
List Price:  FJ$314.80
You save:  FJ$89.95
Q767.29
List Price:  Q1,074.23
You save:  Q306.94
GY$20,923.57
List Price:  GY$29,293.84
You save:  GY$8,370.26
ISK kr12,189.78
List Price:  ISK kr17,066.18
You save:  ISK kr4,876.40
DH904.81
List Price:  DH1,266.78
You save:  DH361.96
L1,669.29
List Price:  L2,337.07
You save:  L667.78
ден5,270.43
List Price:  ден7,378.81
You save:  ден2,108.38
MOP$808.65
List Price:  MOP$1,132.14
You save:  MOP$323.49
N$1,770
List Price:  N$2,478.07
You save:  N$708.07
C$3,680.55
List Price:  C$5,152.92
You save:  C$1,472.36
रु14,026.51
List Price:  रु19,637.67
You save:  रु5,611.16
S/352.78
List Price:  S/493.91
You save:  S/141.12
K415.29
List Price:  K581.42
You save:  K166.13
SAR375.21
List Price:  SAR525.31
You save:  SAR150.10
ZK2,307.71
List Price:  ZK3,230.88
You save:  ZK923.17
L431.54
List Price:  L604.18
You save:  L172.63
Kč2,084.96
List Price:  Kč2,919.02
You save:  Kč834.06
Ft33,678.63
List Price:  Ft47,151.43
You save:  Ft13,472.79
SEK kr950.56
List Price:  SEK kr1,330.83
You save:  SEK kr380.26
ARS$131,661.27
List Price:  ARS$184,331.04
You save:  ARS$52,669.77
Bs691.10
List Price:  Bs967.57
You save:  Bs276.47
COP$399,510.12
List Price:  COP$559,330.15
You save:  COP$159,820.03
₡50,590.43
List Price:  ₡70,828.63
You save:  ₡20,238.19
L2,633.54
List Price:  L3,687.06
You save:  L1,053.52
₲749,023.54
List Price:  ₲1,048,662.92
You save:  ₲299,639.38
$U4,004.24
List Price:  $U5,606.09
You save:  $U1,601.85
zł363.09
List Price:  zł508.35
You save:  zł145.25
Already have an account? Log In

Transcript

Hello, in this python programming tutorial, we are going to look at overriding methods. So we've got this vehicle class right here, we've got this car class right here, which inherits from the vehicle class, Alex that inherits in its attributes, those The, the increase the method, that sort of stuff. But what if we want them slightly slightly different like functionality to one of the methods for increased speed, we can do that. And that's called overriding methods. And the way you do it is simply implement it within the child class. Because if it's not implemented it as the parents behavior as default if it's implemented as its own behavior as default, so for the increased speed, instead, maybe I want to point it instead.

So now, if we were to run this so let's just draw in the coastal you A 10 increase wait for child car, the 19 that's fine, you get zero for the speed so let's increase the speed of the child car. For now let's do child car the increase speed and we'll put five and what's gonna happen still not print zero because the default of zero, so let's just do one instead. So now so look 1019 increase the by fives. We should by default days ending today what we should Zero there, we create the child call in the press in the rerun it, there we go through the 1019. That's fine for increasing speed, it doesn't add it a time does it? Obviously it's a very simple example, but that is the principle of overriding method, a child class.

Now, inherited parents methods, if you want slightly different or you know, entirely different functionality with the same name, same parameter, you know, same structure of calling, essentially, you can override the method. That's it for this video. Thanks for watching and I look forward to seeing you in the next one.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.