Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. class TreasureChest:
  2. # your code goes here
  3. def __init__(self, item):
  4.  
  5. self.item = item
  6. self.is_open = False
  7.  
  8. def print_description(self):
  9.  
  10. if self.is_open:
  11. print(self.item)
  12. else:
  13. print("a locked treasure chest")
  14.  
  15. def open(self):
  16.  
  17. self.is_open = True
  18.  
  19.  
  20. # your code goes here
  21.  
  22. p = TreasureChest("a book of immense Python knowledge")
  23. q = TreasureChest("the guardian of group work")
  24.  
  25. p.print_description()
  26.  
  27. p.open()
  28.  
  29. p.print_description()
  30.  
  31. print("")
  32.  
  33. q.print_description()
  34.  
  35. q.open()
  36.  
  37. q.print_description()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement