Skip to content

Instantly share code, notes, and snippets.

@MLWhiz
Last active November 24, 2020 16:05
Show Gist options
  • Save MLWhiz/587e5bad792b49b2894e94653498036a to your computer and use it in GitHub Desktop.
Save MLWhiz/587e5bad792b49b2894e94653498036a to your computer and use it in GitHub Desktop.
import math
class Shape:
def __init__(self, name):
self.name = name
def area(self):
pass
def getName(self):
return self.name
class Rectangle(Shape):
def __init__(self, name, length, breadth):
super().__init__(name)
self.length = length
self.breadth = breadth
def area(self):
return self.length*self.breadth
class Square(Rectangle):
def __init__(self, name, side):
super().__init__(name,side,side)
class Circle(Shape):
def __init__(self, name, radius):
super().__init__(name)
self.radius = radius
def area(self):
return pi*self.radius**2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment