0. 继承性
1. 对象
2. 默认自己?
3. __(在变量或者函数名前)
4. __init__
5. 没有默认的参数?
#-----定义一个游乐园门票的类-----#
class Ticket:
workday_ticket = 100
weekend_ticket = 1.2 * workday_ticket
def workday(self, n):
workday_money = self.workday_ticket * n
print(workday_money)
def weekend(self, n):
weekend_money = self.weenkend_ticket * n
print(weekend_money)
def child_workday(self, n):
child_workday_money = self.workday_ticket * 0.5
print(child_workday_money)
def child_weekend(self, n):
child_weekend_money = self.weekend_ticket * 0.5
print(child_weekend_money)
class Ticket:
workday_ticket = 100
weekend_ticket = 1.2 * workday_ticket
def workday(self, n):
workday_money = self.workday_ticket * n
print(workday_money)
def weekend(self, n):
weekend_money = self.weenkend_ticket * n
print(weekend_money)
def child_workday(self, n):
child_workday_money = self.workday_ticket * 0.5
print(child_workday_money)
def child_weekend(self, n):
child_weekend_money = self.weekend_ticket * 0.5
print(child_weekend_money)
t = Ticket()
t1 = t.workday(2)
t2 = t.child_workday(1)
print(t1+t2)
t1 = t.workday(2)
t2 = t.child_workday(1)
print(t1+t2)