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 9470a62

Browse files
Merge pull request #5 from PyroCandy/main
Added inheritance.py
2 parents 132a1d8 + f500de9 commit 9470a62

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

‎OOP in Python/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
### Object
44
### Method
55
### Inheritence
6+
7+
Inheritance is defined as one class’s tendency to derive properties and characteristics from other classes. It provides additional functionalities to extract features from the base class and imply it into other derived classes significantly.
8+
69
### Polymorphism
710
### Data Abstraction
811
### Encapsulation

‎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 によって変換されたページ (->オリジナル) /