Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Object Oriented Programming (OOP)
- # Class/ template/ abstract
- # 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
- Hero.amount += 1 # Add 1 for each action
- print("Create human that named by ", inputName)
- hero1 = Hero("sniper", 100, 10, 4)
- print(Hero.amount)
- hero2 = Hero("mirana", 100, 15, 1)
- print(Hero.amount)
- hero3 = Hero("ucup", 1000, 100, 0)
- print(Hero.amount)
- # Link: https://www.youtube.com/watch?v=upngNSC9FU8&list=PLZS-MHyEIRo7ab0-EveSvf4CLdyOECMm0&index=3
Add Comment
Please, Sign In to add comment