Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7 class Room The class Room represents a room in some underground maze; it might be used, perhaps as part of a MUD. Each room

image text in transcribed
image text in transcribed
7 class Room The class Room represents a room in some underground maze; it might be used, perhaps as part of a MUD. Each room has four exits, which often (not always) lead to other rooms. The exits are n,s,w,e - representing the four points of the compass In a real Room object that was part of a game, there would be many different properties (like a description, a list of objects on the floor, etc.). But for our little class, you will only need to support two types of fields: a name (which must be a string) and the four exits. The name must be a private field; thus, you must store it in a variable whose name starts with a single underscore. You must provide a getter and setter for the name. The four exits, however, should be public fields, they should simply have the names n,s,w,e Ench exit is either a reference to another Room object, or else None (meaning that the wall has no exit in that direction) All exits must be symmetric. That is, if you have an East exit that points to another Room, then that Room must have a West exit which comes back to the current room. Next, you will write one non-trivial method: collapse_room(), which rep- resents a cave-in. In this method, which is called on a certain Room, you must set all of the exits of that room to None. In addition, in each adjacent Room, you must set the exit coming back to None as well - so that it's impossible to reach this room anymore, from anywhere else. Define this class inside prob3.py 7.1 Room: Required Methods -init..(self, ????) Your class must include a constructor. However, my testcases will never create any Room objects directly (only through calling build_grid()). so you have total freedom about what you want the parameter(s) to be get_name(self) set_name(self, name) Getter and setter for the room name. The name must always be a string. collapse_room(self) Breaks all exits to and from this room. All of the exits leaving this room are set to None; in addition, in each adjacent room, the link to this room is set to None. 7.2 Factory Function: build.grid In addition to the class. your file prob3.py must also define a function (not a method of any class) named build_grid(uid, hei). This will build a two dimensional grid of Room objects, where the width (that is, the West-East size) and the height (that is, the North-South size) are as given. You may assume (without checking) that the height and width are both > 1. You must allocate all of the necessary Room objects, and link them together with their exits. Rooms on the edge of the grid will have one exit which is None (those in the corner will of course have two Nones). You must return the Room object representing the Southwest corner. Do not return an array or other data structure: you must return a reference to a single object While I don't care what are you give to the various rooms, you must give the rooms different names. You can come up with any scheme that you want (given them grid coordinate names), randomly select names from a pool, etc. However, you must (mehow) guarantee that (a) every name is a string of nonnero length and that (b) no two Rooms in the grid you retum have the Nume

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago