请问这样写哪里有问题呢
class Ticket:
def __init__(self,adult=2,child=1,weekend=False):
self.adult=adult
self.child=child
self.money=100
def caladult(self):
if weekend == True:
self.moneyadult=(1.2)*self.money*self.adult
else:
self.moneyadult=self.money*self.adult
def calchild(self):
if weekend == True:
self.moneychild=(0.6)*self.money*self.child
else:
self.moneychild=(self.money/2)*self.child
def total(self):
print("总共花销为:%s"%(self.moneychild+self.moneyadult))
class Ticket:
def __init__(self,adult=2,child=1,weekend=False):
self.adult=adult
self.child=child
self.money=100
self.weekend=weekend
def caladult(self):
if self.weekend == True:
self.moneyadult=(1.2)*self.money*self.adult
else:
self.moneyadult=self.money*self.adult
def calchild(self):
if self.weekend == True:
self.moneychild=(0.6)*self.money*self.child
else:
self.moneychild=(self.money/2)*self.child
def total(self):
print("总共花销为:%s"%(self.moneychild+self.moneyadult))
weekend要给属性
页:
[1]