Learn
Introduction to Classes
Inheritance
Finally, let’s create an Equilateral
class that inherits from our Triangle
class. (An equilateral triangle is a triangle whose angles are all 60˚, which also means that its three sides are equal in length.)
Instructions
1.
Create a class named Equilateral
that inherits from Triangle
.
Inside Equilateral
, create a member variable named angle
and set it equal to 60
.
Create an __init__()
function with only the parameter self
, and set self.angle1
, self.angle2
, and self.angle3
equal to self.angle
(since an equilateral triangle’s angles will always be 60˚).