SHARE
TWEET

room

a guest Jun 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. room.py
  2.  
  3. class Room:
  4.     def __init__(self, room_name):
  5.         self.name = room_name
  6.         self.description = None
  7.         self.WallColor = None
  8.         self.linked_rooms = {}
  9.  
  10.     def set_description(self, room_description):
  11.         self.description = room_description
  12.  
  13.     def get_description(self):
  14.         return self.description
  15.  
  16.     def set_name(self, name):
  17.         self.name = name
  18.  
  19.     def get_name(self):
  20.         return self.name
  21.  
  22.     def set_wallcolor(self, color):
  23.         self.WallColor = color
  24.  
  25.     def get_wallcolor(self):
  26.         return self.WallColor
  27.  
  28.     def get_details(self):
  29.         for direction in self.linked_rooms:
  30.             room = self.linked_rooms[direction]
  31.             print("The " + room.get_name() + " is " + direction)
  32.         print("test in details")
  33.  
  34.     def describe(self):
  35.         print("This is a", self.get_name(), "with", self.get_wallcolor(), "walls!")
  36.         print(self.description)
  37.         print(self.get_details())
  38.         print("test")
  39.  
  40.  
  41.     def link_room(self, room_to_link, direction):
  42.             self.linked_rooms[direction] = room_to_link
  43.             print(self.name + " - linked rooms :" + repr(self.linked_rooms))
  44.  
  45.  
  46. main.py
  47.  
  48. from room import Room
  49.  
  50. kitchen = Room("kitchen")
  51. dininghall = Room("dining hall")
  52. ballroom = Room("ball room")
  53.  
  54. kitchen.set_wallcolor("green")
  55. dininghall.set_wallcolor("white")
  56. ballroom.set_wallcolor("yellow")
  57.  
  58. kitchen.set_description("A dank and dirty room buzzing with flies.")
  59. dininghall.set_description("A cozy room, decorated with pictures and a lot of candles sitting on a rectangular wooden table.")
  60. ballroom.set_description("A huge hall with space for at least 30 people, big elongated windows with luxurious silk curtains")
  61.  
  62. kitchen.link_room(dininghall, "south")
  63. dininghall.link_room(kitchen, "north")
  64. dininghall.link_room(ballroom, "west")
  65. ballroom.link_room(dininghall, "east")
  66.  
  67. kitchen.describe()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top