diff --git a/funcoes.cpp b/funcoes.cpp index 00ef827b57ea37d7e49ea7d5c5318f29f8b1ffd1..e3ad658684316dbee47e3cbe6403144a1ade6596 100644 --- a/funcoes.cpp +++ b/funcoes.cpp @@ -5,7 +5,7 @@ using namespace std; void menuInicial(){ - cout << "1- Logar na conta." << endl << "2- Criar conta." << endl << "3- Sair." << endl; + cout << "1- Logar na conta." << endl << "2- Criar conta." << endl << "3- Sair."<< endl; } void menuOpcoes(){ @@ -19,11 +19,15 @@ int escolheOp(){ } void criarConta(conta *contas, int *indice){ - cout << "Digite o seu nome:" << endl; + cout << "Digite o seu nome: "; cin >> contas[*indice].nomeCliente; - cout << "Digite o número da conta a ser criada:" << endl; + cout << "Digite sua senha: "; + + cin >> contas[*indice].senha; + + cout << "Digite o número da conta a ser criada: "; cin >> contas[*indice].numeroConta; @@ -138,6 +142,23 @@ void logarConta(conta *contas, int indice){ cout << "1- tentar novamente." << endl << "2- Sair" << endl; op = escolheOp(); }else{ + + cout << "Digite sua senha: "; + int lim = 3; + int sen; + do{ + cin >> sen; + if ( lim == 1){ + cout << "Tentativas expiradas. Conta bloqueada.\n\n\n\n\n\n"; + exit(1); + } + if (sen != contas[indiceAt].senha){ + lim--; + cout << "\nSenha incorreta. (" << lim << ") tentativas restantes." << endl << "Digite sua senha novamente: "; + } + }while(sen != contas[indiceAt].senha); + + do{ system("clear"); cout << "Usuario: " << contas[indiceAt].nomeCliente << endl << endl; diff --git a/funcoes.hpp b/funcoes.hpp index 667a33a5ae59cf29a35e6c1c725c22da4c3bc59b..3206dc1af588a2c9e16193dbb1e4e1fc97fd0bcb 100644 --- a/funcoes.hpp +++ b/funcoes.hpp @@ -1,8 +1,10 @@ #include <iostream> +#include <cstdlib> #ifndef funcoes_hpp #define funcoes_hpp typedef struct { + int senha; int numeroConta; double saldo; char nomeCliente[20]; diff --git a/main.cpp b/main.cpp index 2238a796172020ec2f01315bed99018507b56813..bab5948d1cf95f8931685e04b367f904d7023402 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,5 @@ #include "funcoes.hpp" +#include <cstdlib> #include <iostream> using namespace std; diff --git a/teste b/teste index 42eed55c54aa5e1950e6f96f11c1b8d8e5b61828..9a99ae8b6ae879c6f469d06cce954a41836d0db3 100755 Binary files a/teste and b/teste differ