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
€84.91
List Price:  €118.88
You save:  €33.96
£73.38
List Price:  £102.73
You save:  £29.35
CA$135.89
List Price:  CA$190.25
You save:  CA$54.36
A$137.69
List Price:  A$192.77
You save:  A$55.08
S$126.73
List Price:  S$177.44
You save:  S$50.70
HK$783.49
List Price:  HK$1,096.93
You save:  HK$313.43
CHF 77.87
List Price:  CHF 109.03
You save:  CHF 31.15
NOK kr927.35
List Price:  NOK kr1,298.33
You save:  NOK kr370.97
DKK kr634.52
List Price:  DKK kr888.36
You save:  DKK kr253.83
NZ$167.51
List Price:  NZ$234.52
You save:  NZ$67.01
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,265.76
List Price:  ৳17,172.56
You save:  ৳4,906.79
₹9,448.15
List Price:  ₹13,227.79
You save:  ₹3,779.64
RM392.76
List Price:  RM549.88
You save:  RM157.12
₦136,380.36
List Price:  ₦190,937.96
You save:  ₦54,557.60
₨27,806.42
List Price:  ₨38,930.10
You save:  ₨11,123.68
฿3,218.67
List Price:  ฿4,506.27
You save:  ฿1,287.60
₺4,522.62
List Price:  ₺6,331.86
You save:  ₺1,809.23
B$491.16
List Price:  B$687.64
You save:  B$196.48
R1,635.83
List Price:  R2,290.23
You save:  R654.40
Лв166.09
List Price:  Лв232.53
You save:  Лв66.44
₩144,751.51
List Price:  ₩202,657.91
You save:  ₩57,906.39
₪290.51
List Price:  ₪406.73
You save:  ₪116.21
₱6,072.19
List Price:  ₱8,501.31
You save:  ₱2,429.11
¥15,591.35
List Price:  ¥21,828.52
You save:  ¥6,237.16
MX$1,724.09
List Price:  MX$2,413.80
You save:  MX$689.70
QR364.62
List Price:  QR510.49
You save:  QR145.86
P1,356.01
List Price:  P1,898.47
You save:  P542.45
KSh12,913.70
List Price:  KSh18,079.70
You save:  KSh5,166
E£5,287.97
List Price:  E£7,403.37
You save:  E£2,115.40
ብር15,703.42
List Price:  ብር21,985.42
You save:  ብር6,282
Kz91,840.81
List Price:  Kz128,580.81
You save:  Kz36,740
CLP$90,522.94
List Price:  CLP$126,735.74
You save:  CLP$36,212.80
CN¥681.09
List Price:  CN¥953.55
You save:  CN¥272.46
RD$5,945.28
List Price:  RD$8,323.63
You save:  RD$2,378.35
DA13,216.20
List Price:  DA18,503.21
You save:  DA5,287.01
FJ$218.13
List Price:  FJ$305.40
You save:  FJ$87.26
Q763.07
List Price:  Q1,068.33
You save:  Q305.25
GY$20,914.15
List Price:  GY$29,280.64
You save:  GY$8,366.49
ISK kr12,193.78
List Price:  ISK kr17,071.78
You save:  ISK kr4,878
DH922.21
List Price:  DH1,291.13
You save:  DH368.92
L1,719.82
List Price:  L2,407.82
You save:  L687.99
ден5,252.45
List Price:  ден7,353.64
You save:  ден2,101.19
MOP$806.90
List Price:  MOP$1,129.70
You save:  MOP$322.79
N$1,669.87
List Price:  N$2,337.89
You save:  N$668.01
C$3,670.63
List Price:  C$5,139.03
You save:  C$1,468.40
रु15,203.79
List Price:  रु21,285.91
You save:  रु6,082.12
S/349.81
List Price:  S/489.75
You save:  S/139.94
K434.71
List Price:  K608.62
You save:  K173.90
SAR375.14
List Price:  SAR525.21
You save:  SAR150.07
ZK1,883.37
List Price:  ZK2,636.80
You save:  ZK753.42
L447.38
List Price:  L626.35
You save:  L178.97
Kč2,066.37
List Price:  Kč2,893.01
You save:  Kč826.63
Ft30,506.95
List Price:  Ft42,710.96
You save:  Ft12,204
SEK kr919.65
List Price:  SEK kr1,287.55
You save:  SEK kr367.89
ARS$139,262.04
List Price:  ARS$194,972.43
You save:  ARS$55,710.38
Bs689.44
List Price:  Bs965.25
You save:  Bs275.80
COP$369,970.97
List Price:  COP$517,974.16
You save:  COP$148,003.18
₡45,478.59
List Price:  ₡63,671.85
You save:  ₡18,193.25
L2,652.37
List Price:  L3,713.42
You save:  L1,061.05
₲604,606.62
List Price:  ₲846,473.46
You save:  ₲241,866.83
$U4,017.89
List Price:  $U5,625.21
You save:  $U1,607.32
zł359.44
List Price:  zł503.23
You save:  zł143.79
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.