テキストベースのゲームを作成しています。これは、部屋の属性を確立するために使用しているファイルです。room3 の部屋の説明を印刷してこのファイルをテストしようとすると (room3.desc を印刷)、次のエラーが表示されます: AttributeError: type object 'Room3' has no attribute 'desc'
class Room:
def __init__(self, x, y, desc):
self.x=x
self.y=y
self.desc=desc
class Room1(Room):
def __init__(self, x, y, desc):
super(Room1, self).__init__()
self.x=0
self.y=0
self.desc="""
A Metal Hallway
This place is dimly lit and cool
----------------------------------------------------
You stand in the middle of an intersection in a metal room.
There are blue glowing lamps lighting this area up. There
is a sign on the wall.
----------------------------------------------------
Obvious exits:East, North"""
class Room2(Room):
def __init__(self, x, y, desc):
super(Room2, self).__init__()
self.x=1
self.y=0
self.desc="""
Thacker's Main Control Room
This place is well lit and cool
----------------------------------------------------
There are multiple panels throughout with a variety of levers and buttons.
People stand in uniforms infront of computers, which are scattered throughout the room.
There is a glass window here revealing space.
Thacker is sitting here in the back of the room in a large chair.
----------------------------------------------------
Obvious exits:West"""
class Room3(Room):
def __init__(self, x, y, desc):
super(Room3, self).__init__()
self.x=0
self.y=1
self.desc== """
Large Hanger Bay
This place is well lit and cool
----------------------------------------------------
There are a variety of mobile suits here
----------------------------------------------------
Obvious exits:South"""
print("%s" % Room3.desc)