-1
class Item():
def __init__(self, name, cost, image):
self.name = name
self.cost = cost
self.image = image
class Weapon(Item):
def __init__(self, name, cost, image, damage):
self.damage = damage
super().__init__(name, cost, image)
class W_S(Weapon):
def __init__(self):
super().__init__(name="Wooden Sword", cost = 50, damage = 3, image = pygame.image.load('wood_sword.png')
class S_S(Weapon): #Syntax error here
def __init__(self):
super().__init__(name="Stone Sword", cost = 75, damage = 6, image = pygame.image.load('stone_sword.png')
class I_S(Weapon):
def __init__(self):
super().__init__(name="Iron Sword", cost = 100, damage = 9, image = pygame.image.load('iron_sword.png')
我試圖創建S_S(劍石)基本武器子類,我得到凸顯class S_S(Weapon):
字class
錯誤。在Python特定的子類提供了語法錯誤
如果在看起來好的行上出現語法錯誤,請始終檢查上一行,尤其是對於不匹配的括號或括號。 – user2357112
WOOPS!抓住它,謝謝! –