有没有好的python UML建模工具?求推荐,除eclipse的插件(因为不喜欢用eclipse)。pyNsource用的不是很好,pyUt不全。有没StarUML上的python插件?
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()
原文:http://blog.csdn.net/pandora_madara/article/details/26450219