Inheritance 7/23/2019 Alex Stennet
Inheritance 7 / 23 / 2019 Alex Stennet
Review
Review
WWPD >>>class A: >>>a.X=5 ×=10 >>>A.X def __init__(self,y): 18 self.y =y >>>b.x >>a=A(4) 18 >>>b=A(6) >>>A.X=15 >>>a.X 5 >>>b.X 15
WWPD >>> class A: ... x = 10 ... def __init__(self, y): ... self.y = y ... >>> a = A(4) >>> b = A(6) >>> a.x = 5 >>> A.x >>> b.x >>> A.x = 15 >>> a.x >>> b.x 10 10 5 15
Re-Implement Rationals ●Rational Class o Attributes: ■Numerator 题Denominator o Methods: print()-should print 'numerator denominator' add(other)-should return a new rational with addition of current and other mul(other)-should return a new rational with multiplication of current and other
Re-Implement Rationals ● Rational Class ○ Attributes: ■ Numerator ■ Denominator ○ Methods: ■ print() - should print ‘numerator / denominator’ ■ add(other) - should return a new rational with addition of current and other ■ mul(other) - should return a new rational with multiplication of current and other
Inheritance
Inheritance