python 明天再去看看口袋妖怪的练习

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 明天再去看看口袋妖怪的练习相关的知识,希望对你有一定的参考价值。

#Pokemon Class problem

#Core Pokemon Class
class Pokemon:
	Hp = 1
	Atk = 1
	Def = 1
	SpAtk = 1

#Type classes	
class FireType:
	strength = ["grass", "bug"]
	weakness = ["water", "ground"]
	
class WaterType:
	strength = ["fire", "ground"]
	weakness = ["grass", "electric"]
	
class GroundType:
	strength = ["fire", "electric"]
	weakness = ["water", "flying"]	
	
class FlyingType:
	strength = ["ground"]
	weakness = ["eletric"]
	
class Charmander(Pokemon, FireType):
	
	def __init__(self):
		self.Hp = 50
		self.Atk = 20
		self.Def = 15
		self.SpAtk = 8
		
	def ember(self, pkmn):
		if "fire" in pkmn.weakness:
			pkmn.Hp -= 10
		else:
			pkmn.Hp -= 5
			
	def raise_def(self):
		self.Def += 2
		
		
class CharMeleon(Charmander):
	
	def inferno(self, pkmn):
		if "fire" in pkmn.weakness:
			pkmn.Hp -= 25
			
		elif "fire" in pkmn.strength:
			pkmn.Hp -= 1
		else:
			pkmn.Hp -= 10
			
	def sucker_punch(self, pkmn):
		pkmn.Def -= 4
		
		
class Charzard(CharMeleon, FlyingType):
	
	def fly(self):
		self.Def = 100
		
	def HyperBeam(self, pkmn):
		pkmn.Hp -= 50
		

#Combines the attributes of 2 pokemon 	
def breed_pkmn(c1, c2):
	class NewPkmn(c1, c2):
		pass
	return NewPkmn

以上是关于python 明天再去看看口袋妖怪的练习的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #407 (Div. 2)(争取明天24点前补掉)

python基础学习没有写完明天。。。。。

小练习

python练习题

大数据学习练习3--第二天

Linux命令练习四