示例#1
0
 def creatAccount():
     while True:
         user_name = getInput("Entre com o nome de usuário que deseja\n=>",
                              str)
         if user_name == "" or user_name in users:
             print("Usuário invalido ou ja existente")
             continue
         break
     while True:
         password = getInput("Entre com a senha que deseja\n=>", str)
         if password == "":
             print("Entre com uma senha válida")
             continue
         break
     account_number = randrange(1000, 9999)
     while True:
         agency_number = getInput(
             "Entre com o numero da sua agencia - entre 100 e 999\n=>", int,
             range(100, 1000))
         if agency_number != -100:
             break
     new_user = Account(user_name, password, account_number, agency_number)
     users[user_name] = new_user
     new_user.historic.addHistoric(getDay(), "Criação da conta")
     mensage("Usuário criado com sucesso")
 def setPayment(self, day=None, value=None, recipient=None):
     day = getInput("Entre com o dia desejado para adicionar o agamento fixo\n=>", int, range(1, 31))
     value = getInput("Entre com o valor desejado\n=>", float, range(1, 10000000))
     op = getInput("Deseja adicionar um beneficiado?\n(sim)(nao)=>", str)
     if op == "sim":
         recipient = getInput("Digite o nome do beneficiado\n=>", str)
     new_payment = Payment(day, value, recipient)
     self.schedule.append(new_payment)
     return True
示例#3
0
 def setPayment(self, day=None, value=None, recipient=None):
     day = getInput("Entre com o dia do pagamento\n=>", int, range(1, 31))
     if day == -100:
         return
     value = getInput("Entre com o valor do pagamento\n=>", float,
                      range(1, 10000000))
     if value == -100:
         return
     if input("Deseja adicionar o destinatário?\n(sim)(nao)=>") == "sim":
         recipient = input("Entre com o nome/código do destinatário")
     new_payment = Payment(day, value, recipient)
     self.schedule.append(new_payment)
示例#4
0
 def login():
     user_name = getInput("Entre com o nome de usuário\n=>", str)
     if user_name not in users:
         print("Usuário não encontrado")
         return
     user = users[user_name]
     password = getInput("Entre com a senha\n=>", str)
     if password != user.getPassword():
         print("Senha incorreta")
         return
     mensage("Bem vindo {}".format(user_name))
     menu = UserMenu(user)
示例#5
0
 def balance_op(self):
     methods = [
         None,
         self.balance.incrementBalance,
         self.balance.getBalance,
         self.balance.transfer
     ]
     option = getInput(
         "(1) Realizar depósito\n"
         "(2) Mostrar saldo\n"
         "(3) Realizar transferencia\n"
         "(-1) Cancelar\n"
         "Entre com a opção desejada\n=>",
         int,
         range(1, 4)
     )
     if option is -1:
         print("Operação cancelada")
         return
     if option != -100:
         if option == 1:
             self.historic.addHistoric(getDay(), "Deposito realizado")
         elif option == 3:
             self.historic.addHistoric(getDay(), "transferencia realizada")
         return methods[option]()
示例#6
0
 def addHistoric(self, day=None, action=None):
     if day is None:
         day = getInputDay()
     if action is None:
         action = getInput("Entre com a ação", str)
     new_action = [day, action]
     self.__historic.append(new_action)
     self.__historic = sorted(self.__historic)
示例#7
0
 def setCellphone(self, new_data=None):
     if new_data is None:
         new_data = getInput("Entre com o numero do telefone\n=>", str)
     if len(new_data) != 11:
         print("Numero de telefone invalido")
         return
     self.__cellphone = CellPhone(new_data)
     print("Telefone alterado com sucesso")
示例#8
0
 def setEmail(self, new_data=None):
     if new_data is None:
         new_data = getInput("Entre com o email\n=>", str)
     aux = Email(new_data)
     if aux.checkEmail():
         self.__email = aux
     else:
         print("Erro ao tentar alterar o email\nverifique se informou o email correto")
示例#9
0
 def setGenre(self, new_data=None):
     if new_data is None:
         new_data = getInput("Entre com o genero\n=>", str)
     if new_data == "":
         print("Impossivel inserir novo dado")
         return
     self.__genre = new_data
     print("Genero alterado com sucesso")
示例#10
0
 def setPassword(self, new_password=None):
     if new_password is None:
         new_password = getInput("Entre com a nova senha\n=>", str)
     if new_password == "":
         print("Impossivel alterar a senha\nSENHA VAZIA")
         return
     self.__password = new_password
     print("Senha alterada com sucesso")
示例#11
0
    def login():
        def validatePassword(password, user):
            return True if password is user.getPassword() else False

        def validateUsername(username):
            return users[username] if username in users else None

        user_name = getInput("Entre com o nome de usuário\n=>", str)
        user = validateUsername(user_name)
        if user is None:
            print('Nome de usuário inválido')
            return
        password = getInput("Entre com a senha\n=>", str)
        if validatePassword(password, user):
            mensage("Bem vindo {}".format(user_name))
            menu = UserMenu(user)
        else:
            print("Senha invalida")
            return
示例#12
0
 def getPaymentsDay(self, day=None):
     if day is None:
         day = getInput("Entre com o dia\n=>", int, range(1, 31))
     last = []
     for i in self.schedule:
         if (i.getPayment())[0] is day:
             last.append(i)
     for i in last:
         print(i)
     return last
示例#13
0
    def exec(self):
        while True:
            self.showMenu()
            option = getInput("Entre com a opção desejada\n=>", int,
                              range(1, 3))

            if option == -1:
                return
            elif option != -100:
                self.__methods[option]()
示例#14
0
 def setLogin(self, new_login=None):
     if new_login is None:
         new_login = getInput("Entre com o novo login\n=>", str)
     if new_login == "":
         print("Impossivel alterar o login")
         return
     if new_login in users:
         print("Esse usuário ja existe")
         return
     self.__login = new_login
     print("Login alterado com sucesso")
示例#15
0
 def historic_op(self):
     methods = [
         None,
         self.historic.clearHistoric,
         self.historic.getHistoricDay,
         self.historic.showHistoric
     ]
     option = getInput(
         "(1) Limpar o historico\n"
         "(2) Exibir histórico de um dia específico\n"
         "(3) Exibir histórico do mês\n"
         "(-1) Cancelar\n"
         "entre com a opção desejada\n=>",
         int,
         range(1, 4)
     )
     if option is -1:
         print("Operação cancelada")
         return
     if option != -100:
         return methods[option]()
示例#16
0
    def paymentSchedule(self):
        methods = [
            None,
            self.payment_schedule.setPayment,
            self.payment_schedule.getPaymentSchedule,
            self.payment_schedule.getPaymentsDay
        ]
        option = getInput(
            "(1) Agendar um pagamento\n"
            "(2) Exibir agenda de pagamentos\n"
            "(3) Exibir pagamentos de um dia específico\n"
            "(-1) sair\n"
            "=>", int, range(1, 4)
        )

        if option is -1:
            print("Operação cancelada")
            return
        if option != -100:
            if option == 1:
                self.historic.addHistoric(getDay(), "Despesa adicionada")
            methods[option]()
示例#17
0
 def fixedPayment(self):
     methods = [
         None,
         self.fixed_payment.getPaymentSchedule,
         self.fixed_payment.getPaymentsDay,
         self.fixed_payment.setPayment
     ]
     option = getInput(
             "(1) Ver a agenda de pagamentos fixos\n"
             "(2) Ver os pagamentos de um dia especificos\n"
             "(3) Adicionar um pagamento para determinado dia\n"
             "(-1) Cancelar\n"
             "entre com a opção desejada\n=>",
             int,
             range(1, 4)
         )
     if option is -1:
         print("Operação cancelada")
         return
     if option != -100:
         if option == 3:
             self.historic.addHistoric(getDay(), "Despesa adicionada")
         return methods[option]()
示例#18
0
 def changeData(self):
     methods = [
         None,
         self.setAddress,
         self.setCellphone,
         self.setEmail,
         self.setGenre,
         self.setLogin,
         self.setPassword
     ]
     option = getInput(
         "(1) Alterar endereço\n"
         "(2) Alterar numero do telefone\n"
         "(3) Alterar o email\n"
         "(4) Alterar o genero\n"
         "(5) Alterar o login\n"
         "(6) Alterar a senha\n"
         "(-1) Cancelar",
         int, range(1, 7)
     )
     if option == -1:
         return
     if option != -100:
         methods[option]()
示例#19
0
 def setAddress(self, new_data=None):
     if new_data is None:
         new_data = getInput("Entre com o novo endereço", str)
     self.__address = new_data
示例#20
0
def getInputDay():
    day = getInput("Entre com o dia que deseja\n=>", int, range(1, 31))
    return day