forked from yingl/LintCodeInPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshape_factory.py
More file actions
41 lines (36 loc) · 982 Bytes
/
shape_factory.py
File metadata and controls
41 lines (36 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
class Shape:
def draw(self):
raise NotImplementedError('This method should have implemented.')
class Triangle(Shape):
# Write your code here
def draw(self):
print " /\\"
print " / \\"
print "/____\\"
class Rectangle(Shape):
# Write your code here
def draw(self):
print " ----"
print "| |"
print " ----"
class Square(Shape):
# Write your code here
def draw(self):
print " ----"
print "| |"
print "| |"
print " ----"
class ShapeFactory:
# @param {string} shapeType a string
# @return {Shape} Get object of type Shape
def getShape(self, shapeType):
# Write your code here
if shapeType == 'Square':
return Square()
elif shapeType == 'Triangle':
return Triangle()
elif shapeType == 'Rectangle':
return Rectangle()
else:
return None