我尝试在这里制作一个玩具类
class Toy:
def __init__(self,name,ID,price,age):
self.__ToyName = name
self.__ToyID = ID
self.__Price = price
self.__MinimumAge = int(age)
##some methods here
当我尝试制作一个子类计算机游戏时,我需要制作7个参数(玩具类中有5个)来实例化计算机游戏类,它显示“太多争论(7/5)”
class ComputerGame(Toy):
def __init__(self,name,ID,price,age,catogory,console):
Toy.__init__(self,name,ID,price,age)
self.__Catogory = catogory
self.__Console = console
在这种情况下我该怎么做?
答案 0 :(得分:1)
您需要了解有关super
class ComputerGame(Toy):
def __init__(self, name, ID, price, age, catogory, console):
super(ComputerGame, self).__init__(name, ID, price, age)
self.__Catogory = catogory
self.__Console = console