CS编写
菜鸟级别的我。。。。。
嘻嘻嘻。。。。
class Person:
def __init__(self,name):
self.name=name
self.blood=100
def install_bullet(self,clip,bullet):
clip.save_bullets(bullet)
def install_clip(self,gun,clip):
gun.mounting_clip(clip)
def take_gun(self,gun):
self.gun=gun
def fire(self,enemy):
self.gun.shoot(enemy)
def __str__(self):
return self.name+"剩余血量为:"+str(self.blood)
def lose_blood(self,damage):
self.blood-=damage
class Clip:
def __init__(self,capacity):
self.capacity=capacity
self.current_list=[]
def save_bullets(self,bullet):
if len(self.current_list)<self.capacity:
self.current_list.append(bullet)
def __str__(self):
return "弹夹当前的子弹数量为:"+str(len(self.current_list))+"/"+str(self.capacity)
def launch_bullet(self):
if len(self.current_list)>0:
bullet=self

这篇博客适合计算机科学(CS)的初学者,作者以菜鸟的角度分享了自己的学习经历和初步理解,帮助新手入门。
最低0.47元/天 解锁文章
2589

被折叠的 条评论
为什么被折叠?



