mirror of
https://github.com/Hizenberg469/Python-tutorial.git
synced 2026-04-19 23:12:24 +03:00
OOP finished
This commit is contained in:
37
OOP/game.py
Normal file
37
OOP/game.py
Normal file
@@ -0,0 +1,37 @@
|
||||
class User(object):
|
||||
def __init__(self, email):
|
||||
self.email = email
|
||||
print('init complete')
|
||||
|
||||
def sign_in(self):
|
||||
print('logged in')
|
||||
|
||||
class Wizard(User):
|
||||
def __init__(self, name, power):
|
||||
self.name = name
|
||||
self.power = power
|
||||
|
||||
def attack(self):
|
||||
print(f'attacking with power of {self.power}')
|
||||
|
||||
class Archer(User):
|
||||
def __init__(self, name, arrows):
|
||||
self.name = name
|
||||
self.arrows = arrows
|
||||
|
||||
def check_arrows(self):
|
||||
print(f'{self.arrows} remaining')
|
||||
|
||||
def run(self):
|
||||
print('ran really fast')
|
||||
|
||||
class HybridBorg(Wizard, Archer):
|
||||
def __init__(self, name, power, arrows):
|
||||
Archer.__init__(self, name, arrows)
|
||||
Wizard.__init__(self, name, power)
|
||||
|
||||
hb1 = HybridBorg('borgie', 50, 100)
|
||||
|
||||
print(hb1.check_arrows())
|
||||
print(hb1.attack())
|
||||
print(hb1.sign_in())
|
||||
Reference in New Issue
Block a user