Created
September 20, 2011 13:26
-
-
Save snicol/1229061 to your computer and use it in GitHub Desktop.
shape class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Shape(): | |
def __init__(self, sides, size): | |
self.sides = sides | |
self.size = size | |
def render(self): | |
if self.sides == 0: | |
circle(self.size) | |
else: | |
self.render_polygon() | |
def render_polygon(self): | |
for x in range(self.sides): | |
forward(self.size) | |
left(360 / self.sides) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment