学习Python之练习题——快递价格
题目要求:
请编写程序,设计一个快递员计算器。规则为:
首重3公斤,未超过3公斤:
其他地区,10元
东三省、宁夏、青海、海南,12元
新疆、西藏,20元
港澳台地区、国外,不接受寄件
超过3公斤每公斤加价:
其他地区,5元/公斤
东三省、宁夏、青海、海南,10元/公斤
新疆、西藏,15元/公斤
港澳台地区、国外,联系总公司
代码:
class Cost(object):
def __init__(self, weight, uint_price, first_price):
self.weight = weight
self.first_prcie = first_price
self.uint_price = uint_price
def pay(self):
if self.weight <= 3:
t = self.first_prcie
else:
t = self.first_prcie + (self.weight - 3)*self.uint_price
return t
class Area1(Cost):
def __init__(self, weight, uint_price, first_price):
Cost.__init__(self, weight, uint_price, first_price)
self.first_prcie = 10
self.uint_price =</