标签:cheng port 战斗 战斗机 and 扫描 父类 else range
import randomclass feiji:
changdu = ‘20米‘
wuqi = ‘‘
licheng = ‘1000千米‘
zaizhong = "20吨"
xueliang = 1
def feixing(self):
print(‘开始飞行‘)
def jiayou(self):
print(‘开始加油‘)
class zhandouji(feiji):
num = 1
changdu = ‘5米‘
licheng = ‘500千米‘
zaizhong = "10吨"
xueliang = 3
def init(self,num,wuqi = ‘导弹‘):
self.wuqi = wuqi
self.num = num
def kaihuo(self):
print(self.num,‘号战斗机开始发射‘,self.wuqi )
def zhongdan(self):
self.xueliang = self.xueliang - 1
class yunshuji(feiji):
def init(self,huowu = ‘兵‘):
self.huowu = huowu
changdu = ‘30米‘
licheng = ‘2000千米‘
zaizhong = "100吨"
xueliang = 10
def zhuanghuo(self):
print(‘开始装‘ + self.huowu)
def xiehuo(self):
print(‘开始空投‘+self.huowu)
class wurenji(feiji):
def init(self, deren=‘敌人‘):
self.deren = deren
changdu = ‘3米‘
licheng = ‘2000千米‘
zaizhong = "0千克"
xueliang = 1
def xiehuo(self):
print(‘开始扫描‘+self.deren)
zhandoujiArr = []
for item in range(0,100):
zhandoujiArr.append(zhandouji(item))
for item in range(0,random.randint(1,5)):
zhandoujiArr[10].zhongdan()
if(zhandoujiArr[10].xueliang <= 0):
print(zhandoujiArr[10].num,‘号战斗机已被摧毁‘)
else:
print(zhandoujiArr[10].num,‘号战斗机血量还剩‘,zhandoujiArr[10].xueliang)
标签:cheng port 战斗 战斗机 and 扫描 父类 else range
原文地址:https://blog.51cto.com/14887662/2521453