class MoneyCollector(Role):
    def __init__(self):
        self.balance = Balance()
        self.phone = Phone()

    def withdraw(self, amount):
        if self.balance.amount < amount:
            raise Exception("insufficient money!")
        self.balance.decrease(amount)
        self.phone.send_withdraw_msg(amount)
Example #2
0
class LocalMoneyDest(MoneyDest):
    def __init__(self):
        self.account_info = AccountInfo()
        self.balance = Balance()
        self.phone = Phone()

    def transfer_money_from(self, from_id, amount):
        self.balance.increase(amount)
        self.phone.send_transfer_from_msg(from_id, amount)

    def get_account_id(self):
        return self.account_info.id
class LocalMoneySrc(MoneySrc):
    def __init__(self):
        self.account_info = AccountInfo()
        self.balance = Balance()
        self.phone = Phone()

    def transfer_money_to(self, dest, amount):
        if self.balance.amount < amount:
            raise Exception("insufficient money!")
        dest.transfer_money_from(self.account_info.id, amount)
        self.balance.decrease(amount)
        self.phone.send_transfer_to_msg(dest.get_account_id(), amount)

    def get_amount(self):
        return self.balance.amount
 def __init__(self):
     self.balance = Balance()
     self.phone = Phone()
 def __init__(self):
     self.account_info = AccountInfo()
     self.balance = Balance()
     self.phone = Phone()
 def __init__(self, account_id, phone_number, amount):
     AggregateRoot.__init__(self, account_id)
     self.account_info = AccountInfo(account_id)
     self.phone = Phone(phone_number, self.account_info)
     self.balance = Balance(amount)