Esempio n. 1
0
    def process(self):
        result_message = None
        if self._operation_checker:
            result_message = self._operation_checker.check(self.transfer_from, self.transfer_money)

        if not result_message:
            account_repository = AccountRep.instance()
            for acc in self.transfer_from:
                if isinstance(acc, basestring):
                    transfer_from_account = account_repository.get_account(acc)
                else:
                    transfer_from_account = acc
                transfer_from_account.decrease_cash(self.transfer_money)

            for acc in self.transfer_to:
                if isinstance(acc, basestring):
                    transfer_to_account = account_repository.get_account(acc)
                else:
                    transfer_to_account = acc
                transfer_to_account.increase_cash(self.transfer_money)


        return result_message
 def __init__(self, account, atm):
     self._account = account
     self._atm = atm
     self._operation_checker = OperationChecker(AccountRep.instance(), self._atm)
Esempio n. 3
0
__author__ = 'Kostya'
from account_rep import AccountRep
from atm import ATM
from operation_generator import OperationGenerator
import re


cash_machine = ATM(1000)
account = None
while not account:
    login = raw_input('Enter login: '******'Enter password: '******'Wrong login/password combination!\n'

operations = OperationGenerator(account, cash_machine)
while True:
    command = raw_input('\nEnter command: ')
    match = re.search(r'insert money (?P<money_amount>\d+(\.\d+)?)', command)
    if match:
        operation = operations.put_money_operation(float(match.group('money_amount')))
        result = operation.process()
        if result:
            print result
        else:
            print 'Operation executed successfully'
        continue