Skip to content

Commit 1ad97bf

Browse files
authored
Update Day_13.md
1 parent fa41b5b commit 1ad97bf

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

Status/Day_13.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
# Question 47
3-
### Level 1
3+
### Level 2
44

55
**Question:**
66

@@ -29,7 +29,7 @@ print aCircle.area()
2929
----------------
3030

3131
# Question 48
32-
### Level 1
32+
### Level 2
3333

3434
**Question:**
3535

@@ -59,3 +59,39 @@ print aRectangle.area()
5959
```
6060
----------------
6161

62+
# Question 49
63+
### Level 2
64+
65+
**Question:**
66+
67+
***Define a class named Shape and its subclass Square. The Square class has an init function which takes a length as argument. Both classes have a area function which can print the area of the shape where Shape's area is 0 by default.***
68+
69+
----------------------
70+
### Hints: To override a method in super class, we can define a method with the same name in the super class.
71+
72+
----------------------
73+
74+
**Main author's Solution: Python 2**
75+
```
76+
class Shape(object):
77+
def __init__(self):
78+
pass
79+
80+
def area(self):
81+
return 0
82+
83+
class Square(Shape):
84+
def __init__(self, l):
85+
Shape.__init__(self)
86+
self.length = l
87+
88+
def area(self):
89+
return self.length*self.length
90+
91+
aSquare= Square(3)
92+
print aSquare.area()
93+
```
94+
----------------
95+
**My Solution: Python 3**
96+
```
97+
```

0 commit comments

Comments
 (0)