Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. class Blork:
  2. """Defines the Blork class.
  3. Data attributes: name of type str
  4. height (metres) of type float
  5. has_horns of type bool
  6. """
  7.  
  8. def __init__(self, name, height, has_horns=False, baranges=0):
  9. """Blork constructor"""
  10. self.name = name
  11. self.height = height
  12. self.has_horns = has_horns
  13. self.baranges = baranges
  14.  
  15. def say_hello(self):
  16. """hqweqhwe"""
  17. hello = "Hi! My name is {0}!".format(self.name)
  18. if self.has_horns == True:
  19. print(hello.upper())
  20. elif self.has_horns == None:
  21. print(hello)
  22. else:
  23. print(hello)
  24.  
  25. def __str__(self):
  26. """hqweqhwe"""
  27. if self.has_horns == True:
  28. return "{0} is a {1:.2f} m tall horned blork!".format(self.name, self.height)
  29. else:
  30. return "{0} is a {1:.2f} m tall blork!".format(self.name, self.height)
  31.  
  32. def collect_baranges(number):
  33. """wjeqwenqw"""
  34. number = self.baranges
  35. if number == 0:
  36. self.baranges += 1
  37. else:
  38. self.baranges = self.baranges + number
  39.  
  40. def eat(self):
  41. """qweqweqe"""
  42. if self.baranges > 0:
  43. self.baranges -= 1
  44. self.height += 0.1
  45. else:
  46. print("I dont' have any baranges to eat!")
  47.  
  48. def feast(self):
  49. """Qweqweqwe"""
  50. if self.baranges >= 5:
  51. if self.has_horns == True:
  52. self.eight = self.height + (0.5 * self.height)
  53. if self.has_horns == False:
  54. self.has_hair = True
  55. else:
  56. print("I don't have enough baranges to feast!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement