派生

#!/usr/bin/env python 
# -*- coding: utf-8 -*-

class Hoer:
def __init__(self,nickname,life_value,aggresivity):
self.nickname = nickname
self.life_value = life_value
self.aggresivity = aggresivity


def attack(self,enemy):
enemy.life_value -= self.aggresivity


class Garen(Hoer):
camp = 'Demacia'
def attack(self,enemy):
print('form Garen Class')

class Riven(Hoer):
camp = 'Noxus'

g1 = Garen('草丛伦',100,30)
r1 = Riven('小雯雯',80,50)

g1.attack(r1)
# 打印结果:
form Garen Class

posted on 2019-08-07 11:03  kingforn  阅读(158)  评论(0编辑  收藏  举报