コード例 #1
0
    def __init__(self, money, faceValue):
        '''
		多继承时,调用父类构造方法的格式:父类名.__init__(self,[,参数列表])
		单继承时,调用父类构造方法的格式:super.__init__(self,[,参数列表])
		'''
        Father.__init__(self, money)
        Mother.__init__(self, faceValue)
コード例 #2
0
    def __init__(self):
        ShowBase.__init__(self)
        ShowBase.set_background_color(self, 0.08, 0.08, 0.08, 1)
        render.setAntialias(AntialiasAttrib.MAuto)
        self.disableMouse()

        # create father
        self.father = Father(self.cWriter, self.cManager, self.cReader)

        # create messager
        self.messager = Messager(self.father)

        # inputs
        self.accept('escape', self.debug)

        # try to connect
        self.connect()
コード例 #3
0
class Client(ShowBase):
    # notify
    notify = directNotify.newCategory("lp")

    # network
    cManager = QueuedConnectionManager()
    cListener = QueuedConnectionListener(cManager, 0)
    cReader = QueuedConnectionReader(cManager, 0)
    cWriter = ConnectionWriter(cManager, 0)

    def __init__(self):
        ShowBase.__init__(self)
        ShowBase.set_background_color(self, 0.08, 0.08, 0.08, 1)
        render.setAntialias(AntialiasAttrib.MAuto)
        self.disableMouse()

        # create father
        self.father = Father(self.cWriter, self.cManager, self.cReader)

        # create messager
        self.messager = Messager(self.father)

        # inputs
        self.accept('escape', self.debug)

        # try to connect
        self.connect()

    def debug(self):
        # testing_alert = Alert(-1)
        self.father.set_active_level(NIGHT)

    def connect(self):
        port_address = SERVER_PORT
        ip_address = SERVER_IP
        timeout = 3000

        my_connection = self.cManager.openTCPClientConnection(
            ip_address, port_address, timeout)
        if my_connection:
            self.notify.info("Connected")
            self.father.set_connection(my_connection)
            self.cReader.addConnection(my_connection)

            # tasks
            taskMgr.add(self.messager.check_for_message,
                        "Poll the connection reader", -39)
            taskMgr.doMethodLater(HEARTBEAT_PLAYER, self.messager.heartbeat,
                                  "Send heartbeat")
        else:
            Alert(-2)
            self.father.failed_to_connect()
            self.notify.warning("Could not connect!")
コード例 #4
0
 def __init__(self, money, faceValue):
     Father.__init__(self, money)
     Mother.__init__(self, faceValue)
コード例 #5
0
 def earn(self):
     # 方式一
     return Father.earn(self)
コード例 #6
0
    def __init__(self, money, facevalue):
        Father.__init__(self, money)
        Mother.__init__(self, facevalue)

        print(Father.eat(self))
        print(Mother.eat(self))
コード例 #7
0
ファイル: child.py プロジェクト: stone0630/python
 def __init__(self, money, face):
     Father.__init__(self, money=money)
     Mather.__init__(self, face=face)
コード例 #8
0
ファイル: child.py プロジェクト: Xiaochaosui/python_learning
 def __init__(self, money, faceValue):
     Father.__init__(self, money)
     Mother.__init__(self, faceValue)
     self.height = 170