mercredi 28 juillet 2021

(PYTHON) Calling Class Function(s) of 2 Classes at Each Other

I made two classes that would call each other's function before releasing a result but I'm having trouble making it work, is there a reason why I could call the function of the first class above but not the function of the one below?
HERE IS THE PROGRAM:

    import random

    HAND = []
    DECK = ['Ojama Red', 'Ojama Blue','Ojama Yellow','Ojama Green','Ojama Black', 'Ojama Pink', 'Ojama Lime']

    class A:

        def func1(self):
            random.shuffle(DECK)
            B.func3()
        def func2(self):
            c = DECK[0]
            if c in DECK:
                HAND.append(c)
                DECK.remove(c) 

    class B:
        def func3(self): # STANDBY
            self.func4()
        def func4(self): # DRAW
            A.func2()
            self.func5()
        def func5(self): # MAIN PHASE 1
            print('\n', HAND)
            print('\n', DECK)

    start_game = A()
    start_game.func1()



Aucun commentaire:

Enregistrer un commentaire