Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Object Oriented Programming (OOP)
- # Main class
- class Hero:
- # Class/ static variable
- amount = 0
- # Constructor __init__()
- def __init__(self, inputName, inputHealth, inputPower, inputArmor):
- # Instance variable
- self.name = inputName
- self.health = inputHealth
- self.power = inputPower
- self.armor = inputArmor
- hero1 = Hero("sniper", 100, 10, 4)
- hero2 = Hero("mirana", 100, 15, 1)
- hero3 = Hero("ucup", 1000, 100, 0)
- print(hero1.name)
- print(hero2.health)
- print(hero3.armor)
- # Show All Atribute: Dictionary
- print(hero1.__dict__); print(hero2.__dict__); print(hero3.__dict__)
- print(Hero.__dict__)
- # Link: https://www.youtube.com/watch?v=w9emRmkbeps&list=PLZS-MHyEIRo7ab0-EveSvf4CLdyOECMm0&index=2
Add Comment
Please, Sign In to add comment