だから、私はこの問題に取り組んでいます。誰かが私を正しい方向に向けることができれば、とても感謝しています. 設定させてください。
次のように、クラスで満たされた部屋という名前のPythonファイル/モジュールが1つあります。
class Intro(object):
def __init__(self):
# Setting up some variables here
def description(self):
print "Here is the description of the room you are in"
すべてがクールで正しいのはどれですか? 次に、Engine という名前の別のファイル/モジュールで。私はこれを持っています:
import rooms
class Engine(object):
def __init__(self, first_class):
self.lvl = first_class
def play_it(self):
next_lvl = self.lvl
while True:
# Get the class we're in & run its description
next_lvl.description() # it works.
# But how do I get the next class when this class is done?
私が望んでいることは、各部屋/レベル クラス内のユーザーの決定に基づいていることを確認してください。エンジンは、その記述関数/属性を使用して新しいクラスを呼び出します。それは理にかなっていますか?それとも、これについて考えるべき別の方法はありますか?私は時々お尻を後ろに向けます。ありがとう。