Advertisement
johnpentyrch

room2

May 4th, 2020
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. class Room():
  2.     def __init__(self,room_name):
  3.         self.name=room_name
  4.         self.description=None
  5.         self.linked_rooms = {}
  6.  
  7.        
  8.     def set_description(self, room_description):
  9.         self.description = room_description
  10.        
  11.     def get_description(self):
  12.         return self.description
  13.  
  14.     def set_name(self, room_name):
  15.         self.name = room_name
  16.        
  17.     def get_name(self):
  18.         return self.name
  19.    
  20.     def describe(self):
  21.         print( self.description )
  22.        
  23.     def link_room(self, room_to_link, direction):
  24.         self.linked_rooms[direction] = room_to_link
  25.        
  26.     def get_details(self):
  27.         rname=self.name
  28.         print('\n',rname)
  29.         rdescr=self.description
  30.         print(rdescr)
  31.         for direction in self.linked_rooms:
  32.             room = self.linked_rooms[direction]
  33.             print( "The " + room.get_name() + " is " + direction)
  34.  
  35.  
  36.  
  37. if __name__ == "__main__":
  38.     a=Room('Dinning Room')
  39.     a.set_description('The place to cook')
  40.  
  41.  
  42.     print(a.get_name())
  43.     print(a.get_description())
  44.  
  45.     a.set_name('Bathroom')
  46.     a.set_description('The place to wash your hands')
  47.  
  48.     print(a.get_name())
  49.     print(a.get_description())
  50.     a.describe()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement