1、定义Person类,里面有好人和坏人的属性,以及相关方法。
2、定义Clip,里面有增加子弹和出子弹
3、定义Bullet类,里面有子弹的伤害力
4、定义Gun类,里面有装弹夹,以及枪的射击
5、最后一步,创建对象,调用类。
#CS反恐精英1.0
#1、定义战士和敌人的类
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