Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

Why are buyersupplier relationships important?

Answered: 1 week ago

Question

1. Explain how technology has changed the learning environment.

Answered: 1 week ago