码迷,mamicode.com
首页 > 其他好文 > 详细

yarn 集群部署,遇到的问题小结

时间:2014-05-21 13:58:49      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:desing pattern   python   

有没有好的python UML建模工具?求推荐,除eclipse的插件(因为不喜欢用eclipse)。pyNsource用的不是很好,pyUt不全。有没StarUML上的python插件?


bubuko.com,布布扣


import abc

class AbstractEnemyFactory( object ):
	__metaclass__ = abc.ABCMeta

	@abc.abstractmethod
	def createNinja( self ):
		pass

	@abc.abstractmethod
	def createSwordsman( self ):
		pass


class LowLevelEnemyFactory( AbstractEnemyFactory ):

	def createNinja( self ):
		return LowLevelEnemyNinja()

	def createSwordsman( self ):
		return LowLevelEnemySwordsman()


class HighLevelEnemyFactory( AbstractEnemyFactory ):

	def createNinja( self ):
		return HighLevelEnemyNinja()

	def createSwordsman( self ):
		return HighLevelEnemySwordsman()


class EnemyNinja( object ):

	__metaclass__ = abc.ABCMeta

	@abc.abstractmethod
	def ninjutsu_attack( self ):
		pass


class LowLevelEnemyNinja( EnemyNinja ):

	def __init__( self ):
		self._name = 'LowLevelEnemyNinja'
		self._chakra = 100
		self._attack_power = 5
		self._speed = 10

	def ninjutsu_attack( self ):
		print 'Ninja use ninjutsu.'
		print '[%s]: my chakra is %s and the power of attack is %s'			%( self._name, self._chakra, self._attack_power )


class HighLevelEnemyNinja( EnemyNinja ):

	def __init__( self ):
		self._name = 'EnemyNinja'
		self._chakra = 300
		self._attack_power = 15
		self._speed = 20

	def ninjutsu_attack( self ):
		print 'Ninja use ninjutsu.'
		print '[%s]: my chakra is %s and the power of attack is %s'			%( self._name, self._chakra, self._attack_power )

	def special_effect( self ):
		print '[%s]: special effect!'%( self._name )


class EnemySwordsman( object ):
	
	__metaclass__ = abc.ABCMeta

	@abc.abstractmethod
	def swords_attack( self ):
		pass


class LowLevelEnemySwordsman( EnemySwordsman ):

	def __init__( self ):
		self._name = 'LowLevelEnemySwordsman'
		self._blood = 100
		self._attack_power = 5
		self._speed = 10



	def swords_attack( self ):
		print 'Swordsman use swords.'
		print '[%s]: my blood is %s and the power of attack is %s'			%( self._name, self._blood, self._attack_power )
	


class HighLevelEnemySwordsman( EnemySwordsman ):

	def __init__( self ):
		self._name = 'HighLevelEnemySwordsman'
		self._blood = 300
		self._attack_power = 30
		self._speed = 30

	def swords_attack( self ):
		print 'Swordsman use swords.'
		print '[%s]: my blood is %s and the power of attack is %s'			%( self._name, self._blood, self._attack_power )

	def special_effect( self ):
		print '[%s]: special effect!'


if __name__ == '__main__':

	h = HighLevelEnemyFactory()
	h.createNinja().ninjutsu_attack()
	h.createNinja().special_effect()
	h.createSwordsman().swords_attack()


yarn 集群部署,遇到的问题小结,布布扣,bubuko.com

yarn 集群部署,遇到的问题小结

标签:desing pattern   python   

原文地址:http://blog.csdn.net/uniquechao/article/details/26449761

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!