2018-11-21 12:17

# 利用面向对象技术+数据分析技术实现国际化产科医院不同国籍新生儿出生指标对照分析：体长、体重、肺活量。

**

`````` 基类
class baby:
# 服务于计算全体婴儿的平均指标值
__num=0
__total_breath_val=0
__total_length=0
__total_weight=0
#服务于每个婴儿指标的输入和统计
def __init__(self,x,y,z):
self.__length=x
self.__weight=y
self.__breath=z
baby.__num+=1
baby.__total_breath_val+=z
baby.__total_length+=x
baby.__total_weight+=y

#   服务于输出每个婴儿指标信息
def get(self):
print("婴儿的体长:",self.__length)
print("婴儿的体重:",self.__weight)
print("婴儿的肺活量:",self.__breath)
@classmahtod
def fhz(self):
return  baby.__num,baby.__total_breath_val,baby.__total_length,baby.__total_weight

class chinese_baby(baby):
#服务于计算中国籍婴儿的平均指标值
__num=0
__total_breath_val=0
__total_length=0
__total_weight=0
def __init__(self, x, y, z,k):
super().__init__(x,y,z)
self.__length = x
self.__weight = y
self.__breath = z
self.__sx=k
chinese_baby.__num += 1
chinese_baby.__total_breath_val += z
chinese_baby.__total_length += x
chinese_baby.__total_weight += y
def get(self):
super().get()
print("该婴儿的属相:",self.__sx)
print("婴儿的体长:",self.__length)
print("婴儿的体重:",self.__weight)
print("婴儿的肺活量:",self.__breath)
@classmahtod
def fhz(self):
return  chinese_baby.__num,chinese_baby.__total_breath_val,chinese_baby.__total_length,chinese_baby.__total_weight

class america_baby(baby):
# 服务于计算中国籍婴儿的平均指标值
__num = 0
__total_breath_val = 0
__total_length = 0
__total_weight = 0
def __init__(self, x, y, z, k):
super().__init__(x, y, z)
self.__length = x
self.__weight = y
self.__breath = z
self.__bzh = k
america_baby.__num += 1
america_baby.__total_breath_val += z
america_baby.__total_length += x
america_baby.__total_weight += y
def get(self):
super().get()
print("该婴儿的保障号:", self.__bzh)
print("婴儿的体长:", self.__length)
print("婴儿的体重:", self.__weight)
print("婴儿的肺活量:", self.__breath)

@classmahtod
def fhz(self):
return  america_baby.__num,america_baby.__total_breath_val,america_baby.__total_length,america_baby.__total_weight

if __name__=="__main__":
c_baby=[]
a_baby=[]
while True:
key=input("是否继续接生(y/n)")
if key=="n":
break
key=input("中国孩子还是美国孩子(c/a)")
if key=="c":
x_length=int(input("请输入体长"))
x_weight=int(input("请输入体重"))
x_breath=int(input("请输入肺活量"))
x_sx=input("请输入属相")
c_baby.append(chinese_baby(x_length,x_weight,x_breath,x_sx))
else:
x_length = int(input("请输入体长"))
x_weight = int(input("请输入体重"))
x_breath = int(input("请输入肺活量"))
x_bzh = input("请输入保障号")
a_baby.append(america_baby(x_length, x_weight, x_breath, x_bzh))