Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b2cc5ad

Browse files
created inheritance.py
1 parent 132a1d8 commit b2cc5ad

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎OOP in Python/inheritance.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Champion(object):
2+
3+
def __init__(self, name):
4+
self.name = name
5+
6+
def getName(self):
7+
return self.name
8+
9+
def isChamp(self):
10+
return False
11+
12+
13+
class Champ(Champion):
14+
15+
def isChamp(self):
16+
return True
17+
18+
chmp = Champion("Name1")
19+
print(chmp.getName(), chmp.isChamp())
20+
21+
chmp = Champion("Name2")
22+
print(chmp.getName(), chmp.isChamp())

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /