[Tutor] why wont this code run?
GREENDAY31087@aol.com
GREENDAY31087@aol.com
Sun Jan 26 20:06:02 2003
--part1_110.1f259c3f.2b65dfc1_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
class Map:
def __init__(self):
self.__grid={} # Don't assume global startroom
def addRoom(self, room, x, y):
if self.__grid.has_key((x,y)):
raise KeyError, "Location occupied"
self.__grid[(x, y)] = room
def getRoom(self, x, y):
return self.__grid[(x, y)]
def getLocation(self, room):
for coord, aRoom in self.__grid.items():
if room == aRoom:
return coord
raise KeyError
class Room:
def __init__(self, map, x=0, y=0):
self.__map = map
map.addRoom(self, x, y)
def dig(direction):
--part1_110.1f259c3f.2b65dfc1_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
<HTML><FONT FACE=arial,helvetica><FONT SIZE=2 FAMILY="SANSSERIF" FACE="Arial" LANG="0">class Map:<BR>
def __init__(self):<BR>
self.__grid={} # Don't assume global startroom<BR>
def addRoom(self, room, x, y):<BR>
if self.__grid.has_key((x,y)):<BR>
raise KeyError, "Location occupied"<BR>
self.__grid[(x, y)] = room<BR>
def getRoom(self, x, y):<BR>
return self.__grid[(x, y)]<BR>
def getLocation(self, room):<BR>
for coord, aRoom in self.__grid.items():<BR>
if room == aRoom:<BR>
return coord<BR>
raise KeyError<BR>
<BR>
class Room:<BR>
def __init__(self, map, x=0, y=0):<BR>
self.__map = map<BR>
map.addRoom(self, x, y)<BR>
def dig(direction):<BR>
</FONT></HTML>
--part1_110.1f259c3f.2b65dfc1_boundary--