diff --git a/diy4.py b/diy4.py index a6d3574..9436f5c 100644 --- a/diy4.py +++ b/diy4.py @@ -6,14 +6,15 @@ class Hero: self.attack = attack -def upgrade(): - yase.level += 1 - yase.hp += 50 - yase.attack += 4 + def upgrade(self): + self.level += 1 + self.hp += 50 + self.attack += 4 yase = Hero("亚瑟",300,20) -upgrade() -upgrade() +yase.upgrade() -print("yase的血量为:",yase.hp) \ No newline at end of file +print("亚瑟的等级为:",yase.level) +print("亚瑟的血量为:",yase.hp) +print("亚瑟的攻击力为:",yase.attack) \ No newline at end of file