Question
In simple Python: Create a class called Room, for storing information about the locations that the player and monster will be moving through. Rooms have
In simple Python: Create a class called Room, for storing information about the locations that the player and monster will be moving through. Rooms have two public attributes for storing the name of the room (e.g., "the docking bay" or "a long hallway") and the room number. The constructor should set both a name and a room number Room objects should also have a non-public attribute storing the list* of other Rooms that this Room is connected to. When the constructor creates a new Room, the list of exits should start out as empty.
To add connections between rooms, create a method called .connect_to(), which takes another Room or an iterable of Rooms and adds connections between them. Note that in addition to adding the other Room to the current Room's exit list, you will also need to add the current Room to the other Room's exit list. Since the exit list is not public, you should also create a getter for it.
Write a method called .is_connected_to() which determines whether or not two Rooms are connected. So a command like lab.is_connected_to(hall) would return True if there's a connection between lab and hall, and it would return False if there is no such connection. Write a method called .description() which returns a string representing a description of the Room. The description should include the name of the Room and a list of the room numbers of adjacent rooms.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started