2
私はこの問題を抱えています。誰かが正しい方向に向けることができれば、とても感謝しています。私はあなたのためにそれを設定しましょう。Pythonのあるクラスから別のクラスへ「移動」
私はそうのようなクラスで満たさ1 Pythonのファイル/モジュールという名前の部屋、持っている:すべてのクールなものの権利である
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?
は、私は各部屋/レベルのクラス内でのユーザの判断に基づいて起こるしたいものを参照してください、その説明機能/属性/ wの新しいクラス時にエンジンコール。それは理にかなっていますか?それとも、私はこれについて考えなければならない別の方法がありますか?まあ、後ろ向きです。ありがとう。
[State Pattern](http://en.wikipedia.org/wiki/State_pattern)を見てください... –