|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
class Ticket:
dayPrice = 100
date = int(input('工作日去请输入1,周末去请输入0'))
adult = int(input('成人数量:'))
child = float(input('儿童数量'))
def __init__(self,adult,child):
self.adult = adult
self.child = child
if date:
print(dayPrice*(self.adult+self.child/2))
else:
print(dayPrice*(self.adult+self.child/2*1.2))
t = Ticket()
小白卑微求教,具体错误是怎么回事?不理解原理
- class Ticket:
- dayPrice = 100
- date = int(input('工作日去请输入1,周末去请输入0'))
- def __init__(self, adult, child):
- self.adult = adult
- self.child = child
- if Ticket.date: # 修改
- print(Ticket.dayPrice * (self.adult + self.child / 2)) # 修改
- else:
- print(Ticket.dayPrice * (self.adult + self.child / 2 * 1.2)) # 修改
- adult = int(input('成人数量:'))
- child = float(input('儿童数量'))
- t = Ticket(adult, child) # 修改
复制代码
|
|