Advertisement
kevinbocky

error.py

Dec 30th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. class Room():
  2.  
  3. def __init__(self, room_name):
  4. self.name = room_name
  5. self.description = None
  6. self.linked_rooms ={}
  7.  
  8. def set_name(self, room_name):
  9. self.name = room_name
  10.  
  11.  
  12. def set_description(self, room_description):
  13. self.description = room_description
  14.  
  15.  
  16. def get_description(self):
  17. return(self.description)
  18.  
  19. def describe(self):
  20. print(self.description)
  21.  
  22. def get_name(self):
  23. return (self.name)
  24.  
  25.  
  26.  
  27. def linked_room(self, room_to_link, direction):
  28. self.linked_rooms[direction] = room_to_link
  29. print(self.name + " linked rooms : " + repr(self.linked_rooms))
  30.  
  31.  
  32.  
  33.  
  34. def get_details(self):
  35. for direction in self.linked_rooms:
  36. room = self.linked_rooms[direction]
  37. print("The" + room.get_name() + "is" + direction)
  38.  
  39.  
  40.  
  41.  
  42. from room import Room
  43.  
  44. kitchen = Room("Kitchen")
  45. kitchen.set_description("A dirty room full of rotten food and flies")
  46. kitchen.linked_room("Dining Hall", "South")
  47. kitchen.describe()
  48.  
  49. dining = Room("Dinning hall")
  50. dining.set_description("A wonderfull and large room for christmas dinner")
  51. dining.linked_room("Ballroom", "East")
  52. dining.describe()
  53.  
  54. ballroom = Room("Ballroom")
  55. ballroom.set_description("A wonderfull room for dancing and music")
  56. ballroom.linked_room("Dining Hall", "West")
  57. ballroom.describe()
  58.  
  59. kitchen.get_details()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement