0
基本上是這樣的如何使用我在另一個類中使用的對象的類方法?
class Key:
def __init__(self, pressed):
'''(Key, bool) -> NoneType
'''
self._pressed = pressed
def change_press_state(self):
self._pressed = not self._pressed
class KeyBoard:
def __init__(self, how_many):
'''(KeyBoard, int) -> NoneType
Makes a Keyboard of 'how_many' keys.
'''
self._keys = []
for i in range (0, how_many):
self._keys.append(KeyBoard(False))
def switch_status_of_key(self, index_of_key):
'''(KeyBoard) -> NoneType
Presses key if isn't and stops pressing key if it is.
'''
我怎麼會呼籲用戶要switch_status_of_key切換特定鍵change_press_state? 我在想像
self._keys[key] = self._keys[key].flip()
但顯然不是因爲我得到的錯誤。
啊對!沒有平等,也沒有感謝我剛剛隨這些錯誤而犯下的任何錯誤。 – Krio