Afinal do projeto

This commit is contained in:
250413
2026-06-08 11:19:51 +01:00
parent cd5ebb6faa
commit 4b20447c7a
4 changed files with 104 additions and 115 deletions

View File

@@ -1,4 +1,6 @@
Tiago Silva,195572,913538232,250422@epvc.pt,228389992,500.0 Tiago Silva,195572,913538232,250422@epvc.pt,228389992,500.0
manel,779820,987654321,manel@epvc.pt,123456789,60.0 manel,779820,987654321,manel@epvc.pt,123456789,60.0
Tony Eric Wilson,720726,967761691,tony@mail.pt,228389992,1000.0 Tony Eric Wilson,720726,967761691,tony@mail.pt,228389992,1000.0
Eric,390298,938624267,e@e.pt,228389992,654783.0 Eric,390298,938624267,e@e.pt,228389992,654803.0
Tomás,507712,967761691,tiago@mail.com,228389992,385.0
Wilson,755137,909876543,ftyj@eptp.com,228389992,700.0

View File

@@ -1 +1,11 @@
ouwefh, 934384261, rua alexandre de morais, 38, 25/11/2012, Cinquenta euros, valor, ilhbv ouwefh, 934384261, rua alexandre de morais, 38, 25/11/2012, Cinquenta euros, valor, ilhbv
Vendeiro, 913538232, Póvoa de Varzim, 25/05/2023, Duzentos e cinquenta e seis euros, valor, Eric
Vendeiro, 946823523, Póvoa de Varzim, 24/07/2023, Trezentos e cinquenta e quatro euros, valor, Eric
Vendeiro, 940736325, Vila do Conde, 23/07/2023, Quatrocentos e vinte e cinco euros e cinquenta e seis cêntimos, valor, Eric
tiago, 912345678, Porto, 23/07/2023, Cento e vinte e três euros e quarenta e cinco cêntimos, valor, Eric
Vendeiro, 987654321, Porto, 11/07/2023, Quatrocentos euros e dois cêntimos, valor, Wilson
Vendeiro, 987654321, Porto, 23/04/2023, Duzentos euros e um cêntimo, valor, Wilson
vendeiro, 987654321, Porto, 23/07/2023, Duzentos euros, valor, Wilson
e, 987654321, e, 23/07/2023, Duzentos euros e dois cêntimos, valor, Wilson
e, 987654321, e, , Duzentos euros, valor, e
e, 987654321, e, 23/07/2023, Duzentos euros e dois cêntimos, valor, Wilson

View File

@@ -266,7 +266,8 @@ private static void menuClienteLogado(String[] dadosCliente) {
"║ ▸ 3 Depositar ║\n" + "║ ▸ 3 Depositar ║\n" +
"║ ▸ 4 Levantar dinheiro ║\n" + "║ ▸ 4 Levantar dinheiro ║\n" +
"║ ▸ 5 Cheque ║\n" + "║ ▸ 5 Cheque ║\n" +
"║ ▸ 6 Sair \n" + "║ ▸ 6 Cambio\n" +
"║ ▸ 7 Sair ║\n" +
"╚═════════════════════════════════════════╝\n", "╚═════════════════════════════════════════╝\n",
"SEU SALDO: " + saldo); "SEU SALDO: " + saldo);
@@ -277,7 +278,7 @@ private static void menuClienteLogado(String[] dadosCliente) {
mostrarDadosCliente(dadosCliente); mostrarDadosCliente(dadosCliente);
break; break;
case 2: case 2:
saldo = transferirDinheiro(dadosCliente[1], saldo); saldo = transferirDinheiro(dadosCliente[2], saldo);
atualizarSaldoCliente(dadosCliente[1], saldo); atualizarSaldoCliente(dadosCliente[1], saldo);
break; break;
case 3: case 3:
@@ -289,7 +290,9 @@ private static void menuClienteLogado(String[] dadosCliente) {
atualizarSaldoCliente(dadosCliente[1], saldo); atualizarSaldoCliente(dadosCliente[1], saldo);
break; break;
case 5 : cheque(); case 5 : cheque();
case 6: break;
case 6 : moeda();
case 7:
sair = true; sair = true;
System.out.println("A sair da conta..."); System.out.println("A sair da conta...");
break; break;
@@ -311,13 +314,13 @@ private static void menuClienteLogado(String[] dadosCliente) {
System.out.println ("╚════════════════════════════════════════╝\n"); System.out.println ("╚════════════════════════════════════════╝\n");
} }
private static double transferirDinheiro(String idOrigem, double saldoOrigem) { private static double transferirDinheiro(String telOrigem, double saldoOrigem) {
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
System.out.print("Digite o ID do cliente destinatário: "); System.out.print("Digite o número de Telefone do destinatário: ");
String idDestino = scanner.nextLine(); String telDestino = scanner.nextLine();
if (idDestino.equals(idOrigem)) { if (telDestino.equals(telOrigem)) {
System.out.println("Não pode transferir para si mesmo!"); System.out.println("Não pode transferir para si mesmo!");
return saldoOrigem; return saldoOrigem;
} }
@@ -334,22 +337,11 @@ private static void menuClienteLogado(String[] dadosCliente) {
System.out.println("Saldo insuficiente!"); System.out.println("Saldo insuficiente!");
return saldoOrigem; return saldoOrigem;
} }
saldoOrigem = saldoOrigem - valor;
String[] dadosDestino = procurarClientePorId(idDestino); atualizarSaldoCliente(telOrigem, saldoOrigem);
if (dadosDestino == null) {
System.out.println("Cliente destinatário não encontrado!");
return saldoOrigem;
}
double saldoDestino = Double.parseDouble(dadosDestino[5]) + valor;
saldoOrigem -= valor;
atualizarSaldoCliente(idDestino, saldoDestino);
atualizarSaldoCliente(idOrigem, saldoOrigem);
System.out.printf("Transferência de "+valor+" realizada com sucesso!\n", valor); System.out.printf("Transferência de "+valor+" realizada com sucesso!\n", valor);
System.out.printf("Novo saldo:"+valor+"\n", saldoOrigem);
return saldoOrigem; return saldoOrigem;
} }
@@ -466,7 +458,7 @@ private static void menuAdmin() {
+ "║ ▸ 2 Procurar cliente ║\n" + "║ ▸ 2 Procurar cliente ║\n"
+ "║ ▸ 3 Editar dados de cliente ║\n" + "║ ▸ 3 Editar dados de cliente ║\n"
+ "║ ▸ 4 Remover cliente ║\n" + "║ ▸ 4 Remover cliente ║\n"
+ "║ ▸ 5 Estatísticas do sistema\n" + "║ ▸ 5 Estatisticas \n"
+ "║ ▸ 6 Sair ║\n" + "║ ▸ 6 Sair ║\n"
+ "╚════════════════════════════════════════╝\n"); + "╚════════════════════════════════════════╝\n");
@@ -485,9 +477,7 @@ private static void menuAdmin() {
case 4: case 4:
removerCliente(); removerCliente();
break; break;
case 5: case 5:mostrarEstatisticas();
mostrarEstatisticas();
break;
case 6: case 6:
sair = true; sair = true;
break; break;
@@ -687,14 +677,14 @@ private static void mostrarEstatisticas() {
double saldoMedio = saldoTotal / numClientes; double saldoMedio = saldoTotal / numClientes;
System.out.println("\n╔════════════════════════════════════════════════════════════════╗"); System.out.println("\n╔════════════════════════════════════════════════════════════════╗");
System.out.println( "║ ESTATÍSTICAS DO SISTEMA ║"); System.out.println("║ ESTATÍSTICAS DO SISTEMA ║");
System.out.println( "╠════════════════════════════════════════════════════════════════╣"); System.out.println("╠════════════════════════════════════════════════════════════════╣");
System.out.printf( "\n", "Total de clientes: " + numClientes); System.out.printf("Total de clientes: %d%44s%n", numClientes, "");
System.out.printf( "\n", String.format("Saldo total do banco: ", saldoTotal)); System.out.printf("Saldo total do banco: %.2f%33s%n", saldoTotal, "");
System.out.printf( "\n", String.format("Saldo médio por cliente: ", saldoMedio)); System.out.printf("Saldo médio por cliente: %.2f%30s%n", saldoMedio, "");
System.out.printf( "\n", String.format("Cliente com maior saldo: ", clienteSaldoMaximo, saldoMaximo)); System.out.printf("Cliente com maior saldo: %s (%.2f)%23s%n", clienteSaldoMaximo, saldoMaximo, "");
System.out.printf( "\n", String.format("Cliente com menor saldo: ", clienteSaldoMinimo, saldoMinimo)); System.out.printf("Cliente com menor saldo: %s (%.2f)%26s%n", clienteSaldoMinimo, saldoMinimo, "");
System.out.println( "╚════════════════════════════════════════════════════════════════╝\n"); System.out.println("╚════════════════════════════════════════════════════════════════╝\n");
} }
private static void atualizarClienteCompleto(String[] dados) { private static void atualizarClienteCompleto(String[] dados) {
@@ -1007,10 +997,11 @@ public static void editarDinheiroCliente() {
System.out.println("║ ID gerado: " + idTitular); System.out.println("║ ID gerado: " + idTitular);
String nif; String nif;
do {
System.out.print("║ Introduza NIF (9 dígitos): "); System.out.print("║ Introduza NIF (9 dígitos): ");
nif = scanner.nextLine(); nif = scanner.nextLine();
while (!verificarNIF(nif) || nif.isEmpty());{
if (!verificarNIF(nif)) { if (!verificarNIF(nif)) {
System.out.println("║ NIF inválido! Deve ter 9 dígitos válidos."); System.out.println("║ NIF inválido! Deve ter 9 dígitos válidos.");
} else if (nifJaExiste(nif)) { } else if (nifJaExiste(nif)) {
@@ -1018,13 +1009,14 @@ public static void editarDinheiroCliente() {
System.out.println("║ Por favor, insira um NIF diferente."); System.out.println("║ Por favor, insira um NIF diferente.");
nif = ""; nif = "";
} }
} while (!verificarNIF(nif) || nif.isEmpty()); }
String telefone; String telefone;
System.out.print("║ Introduza telefone (9 dígitos): "); System.out.print("║ Introduza telefone (9 dígitos): ");
telefone = scanner.nextLine(); telefone = scanner.nextLine();
while (telefone.isEmpty() || telefone.length() != 9 || !telefone.matches("\\d+")){
if (telefone.length() != 9 || !telefone.matches("\\d+")) { if (telefone.length() != 9 || !telefone.matches("\\d+")) {
System.out.println("║ Telefone inválido! Deve ter 9 dígitos."); System.out.println("║ Telefone inválido! Deve ter 9 dígitos.");
} else if (telefoneJaExiste(telefone)) { } else if (telefoneJaExiste(telefone)) {
@@ -1032,7 +1024,7 @@ public static void editarDinheiroCliente() {
System.out.println("║ Por favor, insira um telefone diferente."); System.out.println("║ Por favor, insira um telefone diferente.");
telefone = ""; telefone = "";
} }
while (telefone.isEmpty() || telefone.length() != 9 || !telefone.matches("\\d+")); }
String email; String email;
@@ -1062,7 +1054,7 @@ public static void editarDinheiroCliente() {
String cliente = nome + "," + idTitular + "," + telefone + "," + email + "," + nif + "," + saldoTxt + "\n"; String cliente = nome + "," + idTitular + "," + telefone + "," + email + "," + nif + "," + saldoTxt + "\n";
adicionaTextoAoFicheiro(cliente, "clientes.txt"); adicionaTextoAoFicheiro(cliente, "clientes.txt");
} }
// Taxas baseadas no EURO // Taxas baseadas no EURO
static double[] taxas = { static double[] taxas = {
@@ -1144,81 +1136,66 @@ public static void editarDinheiroCliente() {
} }
public static void moeda() { public static void moeda() {
Scanner sc = new Scanner(System.in);
int opcao;
Scanner sc = new Scanner(System.in); do {
System.out.println("\n=== MOEDAS DISPONIVEIS === " + " ⣀⣠⣤⣤⣤⣀⡀");
System.out.println("1 - EUR — € — European Union " + " ⣀⣴⣿⣿⠿⠿⠿⠿⢿⣿⣷⠄");
System.out.println("2 - USD — $ — United States " + " ⢀⣴⣿⠟⠉⠀⠀⠀⠀⠀⠀⠈⠉⠀");
System.out.println("3 - JPY — ¥ — Japan " + " ⣀⣀⣀⣾⣿⣇⣀⣀⣀⣀⣀⣀⣀⣀⠀");
System.out.println("4 - GBP — £ — United Kingdom " + " ⠛⠛⢻⣿⣿⠛⠛⠛⠛⠛⠛⠛⠛⠛⠀");
System.out.println("5 - CNY — ¥ — China " + " ⣤⣤⣼⣿⣿⣤⣤⣤⣤⣤⣤⣤⣤⣤⠀");
System.out.println("6 — AUD — A$ — Australia " + " ⠉⠉⠉⢿⣿⣏⠉⠉⠉⠉⠉⠉⠉⠉⠀");
System.out.println("7 — CAD — C$ — Canada " + " ⠈⢻⣿⣦⣀⠀⠀⠀⠀⠀⠀⢀⣀⠀");
System.out.println("8 — CHF — Fr — Switzerland " + " ⠉⠻⣿⣿⣶⣶⣶⣶⣿⣿⡿⠃⠀\n"
+ " ⠉⠙⠛⠛⠛⠉⠁⠀⠀⠀");
int opcao = 1; int origem = 0;
while (true) {
System.out.print("\nEscolha a moeda a converter: ");
origem = sc.nextInt();
if (origem >= 1 && origem <= 8) break;
System.out.println("Opção inválida. Insira novamente.");
}
while (opcao != 0) { int destino = 0;
while (true) {
System.out.print("Escolha a moeda pretendida: ");
destino = sc.nextInt();
if (destino >= 1 && destino <= 8) break;
System.out.println("Opção inválida. Insira novamente.");
}
System.out.println("\n=== MOEDAS DISPONIVEIS === "+ " ⣀⣠⣤⣤⣤⣀⡀"); System.out.print("Valor a converter: ");
System.out.println("1 - EUR — € — European Union "+ " ⣀⣴⣿⣿⠿⠿⠿⠿⢿⣿⣷⠄"); double valor = sc.nextDouble();
System.out.println("2 - USD — $ — United States "+ " ⢀⣴⣿⠟⠉⠀⠀⠀⠀⠀⠀⠈⠉⠀");
System.out.println("3 - JPY — ¥ — Japan "+ " ⣀⣀⣀⣾⣿⣇⣀⣀⣀⣀⣀⣀⣀⣀⠀");
System.out.println("4 - GBP — £ — United Kingdom "+ " ⠛⠛⢻⣿⣿⠛⠛⠛⠛⠛⠛⠛⠛⠛⠀");
System.out.println("5 - CNY — ¥ — China "+ " ⣤⣤⣼⣿⣿⣤⣤⣤⣤⣤⣤⣤⣤⣤⠀");
System.out.println("6 - AUD — A$ — Australia "+ " ⠉⠉⠉⢿⣿⣏⠉⠉⠉⠉⠉⠉⠉⠉⠀");
System.out.println("7 - CAD — C$ — Canada "+ " ⠈⢻⣿⣦⣀⠀⠀⠀⠀⠀⠀⢀⣀⠀");
System.out.println("8 - CHF — Fr — Switzerland "+ " ⠉⠻⣿⣿⣶⣶⣶⣶⣿⣿⡿⠃⠀\n"
+ " ⠉⠙⠛⠛⠛⠉⠁⠀⠀⠀" );
int origem; double resultado = converter(valor, origem - 1, destino - 1);
while (true) {
System.out.print("\nEscolha a moeda a converter: ");
origem = sc.nextInt();
if (origem >= 1 && origem <= 8) break;
System.out.println("Opção invalida. Insira novamente."); System.out.println("\n=== RESULTADO ===");
System.out.println(valor + " " + simboloMoeda(origem) +
" = " + resultado + " " + simboloMoeda(destino));
} System.out.println("\n1 - Nova conversão");
System.out.println("2 - Sair");
System.out.print("Opção: ");
opcao = sc.nextInt();
int destino; switch(opcao) {
case 1: //Repetir
break;
case 2:
System.out.println("A sair da conversão de moedas...");
break;
default:
System.out.println("Opção inválida! A encerrar...");
opcao = 2;
}
while (true) { } while (opcao != 2);
System.out.print("Escolhe a moeda pretendida: "); System.out.println("Programa terminado.");
}
destino = sc.nextInt();
if (destino >= 1 && destino <= 8) break;
System.out.println("Opção invalida. Insira novamente.");
}
System.out.print("Valor a converter: ");
double valor = sc.nextDouble();
double resultado = converter(valor, origem - 1, destino - 1);
System.out.println("\n=== RESULTADO ===");
System.out.println(valor + " " +
simboloMoeda(origem) +
" = " +
resultado +
" " +
simboloMoeda(destino));
System.out.println("\n1 - Nova conversão");
System.out.println("0 - Sair");
System.out.print("Opção: ");
opcao = sc.nextInt();
}
System.out.println("Programa terminado.");
}
private static final String[] UNIDADES = { private static final String[] UNIDADES = {
"zero", "um", "dois", "três", "quatro", "zero", "um", "dois", "três", "quatro",
"cinco", "seis", "sete", "oito", "nove" "cinco", "seis", "sete", "oito", "nove"
@@ -1286,7 +1263,7 @@ public static void editarDinheiroCliente() {
System.out.println("│ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ │"); System.out.println("│ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ │");
System.out.println("│ │"); System.out.println("│ │");
System.out.println("│ Pague por este cheque a: │"); System.out.println("│ Pague por este cheque a: │");
System.out.printf( "│ %-60s │%n", beneficiario); System.out.printf( " %-59s │%n", beneficiario);
System.out.println("│ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ │"); System.out.println("│ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ │");
System.out.println("│ │"); System.out.println("│ │");
System.out.printf( "│ A quantia de: %-45s │%n", quantiaPorExtenso); System.out.printf( "│ A quantia de: %-45s │%n", quantiaPorExtenso);
@@ -1297,7 +1274,7 @@ public static void editarDinheiroCliente() {
System.out.println("│ │"); System.out.println("│ │");
System.out.printf( "│ %45s │%n", assinatura); System.out.printf( "│ %45s │%n", assinatura);
System.out.println("│ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ │"); System.out.println("│ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ ̅ │");
System.out.printf( "│ %46s │%n", "Assinatura"); System.out.printf( "│ %45s │%n", "Assinatura ");
System.out.println( "│ │"); System.out.println( "│ │");
System.out.println("└──────────────────────────────────────────────────────────────┘"); System.out.println("└──────────────────────────────────────────────────────────────┘");