AI Features

Solution Review 1: Override a Method using the Super Function

This review provides a detailed explanation of the 'Override a Method using the Super Function' challenge.

We'll cover the following...

Solution

Python 3.5
# Parent Class
class Shape:
sname = "Shape"
def getName(self):
return self.sname
# child class
class XShape(Shape):
# initializer
def __init__(self, name):
self.xsname = name
def getName(self): # overriden method
return (super().getName() + ", " + self.xsname)
circle = XShape("Circle")
print(circle.getName())
...
Ask