2016-02-18 35 views
-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特定的子類提供了語法錯誤

+0

如果在看起來好的行上出現語法錯誤,請始終檢查上一行,尤其是對於不匹配的括號或括號。 – user2357112

+0

WOOPS!抓住它,謝謝! –

回答

1

您在所有呼叫super()的行的末尾都缺少一個關閉paren。

+1

(除了在'Item'類中調用'__init__'方法的'Weapon'類) – ppperry