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.51
List Price:  €119.72
You save:  €34.20
£73.90
List Price:  £103.47
You save:  £29.56
CA$136.90
List Price:  CA$191.66
You save:  CA$54.76
A$151.80
List Price:  A$212.53
You save:  A$60.72
S$127.94
List Price:  S$179.12
You save:  S$51.18
HK$784.91
List Price:  HK$1,098.91
You save:  HK$313.99
CHF 79.57
List Price:  CHF 111.40
You save:  CHF 31.83
NOK kr1,010.31
List Price:  NOK kr1,414.48
You save:  NOK kr404.16
DKK kr638.05
List Price:  DKK kr893.30
You save:  DKK kr255.24
NZ$166.08
List Price:  NZ$232.52
You save:  NZ$66.44
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳12,166.73
List Price:  ৳17,033.91
You save:  ৳4,867.18
₹8,576.47
List Price:  ₹12,007.40
You save:  ₹3,430.93
RM425.20
List Price:  RM595.30
You save:  RM170.10
₦153,083.69
List Price:  ₦214,323.29
You save:  ₦61,239.60
₨28,457.96
List Price:  ₨39,842.28
You save:  ₨11,384.32
฿3,241.77
List Price:  ฿4,538.61
You save:  ฿1,296.84
₺4,016.97
List Price:  ₺5,623.92
You save:  ₺1,606.95
B$553.52
List Price:  B$774.95
You save:  B$221.43
R1,783.60
List Price:  R2,497.11
You save:  R713.51
Лв167.26
List Price:  Лв234.17
You save:  Лв66.91
₩137,424.86
List Price:  ₩192,400.31
You save:  ₩54,975.44
₪333.46
List Price:  ₪466.86
You save:  ₪133.39
₱5,649.68
List Price:  ₱7,909.78
You save:  ₱2,260.09
¥14,680.13
List Price:  ¥20,552.77
You save:  ¥5,872.64
MX$1,867.95
List Price:  MX$2,615.20
You save:  MX$747.25
QR364.18
List Price:  QR509.86
You save:  QR145.68
P1,333.20
List Price:  P1,866.54
You save:  P533.33
KSh12,918.70
List Price:  KSh18,086.70
You save:  KSh5,168
E£4,950.01
List Price:  E£6,930.21
You save:  E£1,980.20
ብር13,536.14
List Price:  ብር18,951.14
You save:  ብር5,415
Kz91,186.39
List Price:  Kz127,664.59
You save:  Kz36,478.20
CLP$94,996.49
List Price:  CLP$132,998.89
You save:  CLP$38,002.40
CN¥716.72
List Price:  CN¥1,003.44
You save:  CN¥286.72
RD$6,015.80
List Price:  RD$8,422.37
You save:  RD$2,406.56
DA12,975.83
List Price:  DA18,166.68
You save:  DA5,190.85
FJ$224.10
List Price:  FJ$313.75
You save:  FJ$89.65
Q768.63
List Price:  Q1,076.11
You save:  Q307.48
GY$20,933.06
List Price:  GY$29,307.13
You save:  GY$8,374.06
ISK kr12,176.78
List Price:  ISK kr17,047.98
You save:  ISK kr4,871.20
DH899.63
List Price:  DH1,259.52
You save:  DH359.89
L1,695.54
List Price:  L2,373.83
You save:  L678.28
ден5,263.48
List Price:  ден7,369.09
You save:  ден2,105.60
MOP$809
List Price:  MOP$1,132.64
You save:  MOP$323.63
N$1,776.31
List Price:  N$2,486.90
You save:  N$710.59
C$3,679
List Price:  C$5,150.76
You save:  C$1,471.75
रु13,709.03
List Price:  रु19,193.20
You save:  रु5,484.16
S/354.56
List Price:  S/496.40
You save:  S/141.84
K412.43
List Price:  K577.42
You save:  K164.99
SAR375.01
List Price:  SAR525.03
You save:  SAR150.02
ZK2,423.83
List Price:  ZK3,393.47
You save:  ZK969.63
L434.35
List Price:  L608.12
You save:  L173.76
Kč2,108.68
List Price:  Kč2,952.24
You save:  Kč843.56
Ft34,161.31
List Price:  Ft47,827.21
You save:  Ft13,665.89
SEK kr953.06
List Price:  SEK kr1,334.33
You save:  SEK kr381.26
ARS$125,561.90
List Price:  ARS$175,791.68
You save:  ARS$50,229.78
Bs688.51
List Price:  Bs963.94
You save:  Bs275.43
COP$401,926.41
List Price:  COP$562,713.05
You save:  COP$160,786.64
₡50,460.13
List Price:  ₡70,646.21
You save:  ₡20,186.07
L2,631.26
List Price:  L3,683.87
You save:  L1,052.60
₲775,455.63
List Price:  ₲1,085,668.91
You save:  ₲310,213.27
$U4,043.06
List Price:  $U5,660.45
You save:  $U1,617.38
zł363.84
List Price:  zł509.39
You save:  zł145.55
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.