Advertisement
Ruslan_nig

OOP1

Feb 6th, 2020
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. #class it is a structure of object
  2.  
  3. class GamePerson:
  4.     # атрибуты класса
  5.     name = "PersonName"
  6.     Slogan = "Person SLogan" #string
  7.     conjure = True #or False
  8.     Power = 200
  9.     armor = [25, 37, 40] #список, массив
  10.     Artefacts = {}#множество
  11.     AssosiationDict = dict()
  12.  
  13.     #методы класса
  14.     def doLive(self):
  15.         print("live method")
  16.  
  17.     def doDeath(self):
  18.         print("death Meathod")
  19.  
  20.     def doBattle(self, way, reaction, stamina):
  21.         self.way = way
  22.         self.reaction = reaction
  23.         self.stamina = stamina
  24.  
  25. #let's create object of class
  26. PersonOne = GamePerson()
  27. PersonTwo = GamePerson()
  28.  
  29. print("Тип данного объекта",type(PersonOne))
  30.  
  31. PersonOne.doLive()
  32.  
  33. print(PersonOne.Slogan)
  34. PersonOne.Slogan = "I have got the power"
  35. print(PersonOne.Slogan)
  36.  
  37. PersonTwo.doBattle(True, 30,"greate")
  38. print(PersonTwo.way)
  39.  
  40. #print(dir(PersonOne))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement