Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- room.py
- class Room:
- def __init__(self, room_name):
- self.name = room_name
- self.description = None
- self.WallColor = None
- self.linked_rooms = {}
- def set_description(self, room_description):
- self.description = room_description
- def get_description(self):
- return self.description
- def set_name(self, name):
- self.name = name
- def get_name(self):
- return self.name
- def set_wallcolor(self, color):
- self.WallColor = color
- def get_wallcolor(self):
- return self.WallColor
- def get_details(self):
- for direction in self.linked_rooms:
- room = self.linked_rooms[direction]
- print("The " + room.get_name() + " is " + direction)
- print("test in details")
- def describe(self):
- print("This is a", self.get_name(), "with", self.get_wallcolor(), "walls!")
- print(self.description)
- print(self.get_details())
- print("test")
- def link_room(self, room_to_link, direction):
- self.linked_rooms[direction] = room_to_link
- print(self.name + " - linked rooms :" + repr(self.linked_rooms))
- main.py
- from room import Room
- kitchen = Room("kitchen")
- dininghall = Room("dining hall")
- ballroom = Room("ball room")
- kitchen.set_wallcolor("green")
- dininghall.set_wallcolor("white")
- ballroom.set_wallcolor("yellow")
- kitchen.set_description("A dank and dirty room buzzing with flies.")
- dininghall.set_description("A cozy room, decorated with pictures and a lot of candles sitting on a rectangular wooden table.")
- ballroom.set_description("A huge hall with space for at least 30 people, big elongated windows with luxurious silk curtains")
- kitchen.link_room(dininghall, "south")
- dininghall.link_room(kitchen, "north")
- dininghall.link_room(ballroom, "west")
- ballroom.link_room(dininghall, "east")
- kitchen.describe()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement