Olá guj, estou tentando fazer um sistema de cadastro de pessoas e existe uma funçao na qual eu preciso buscar as pessoas pelo nome, codigo e cpf/cnpj pelo array de lista de clientes. Porém esta função de busca não está funcionando. Se algum monstro sagrado puder me ajudar 
/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
*/
package projetoic;
import java.util.ArrayList;
import java.util.Scanner;
/**
*
-
@author flavi */ public class Main { public static ArrayList lista_clientes = new ArrayList<>(); //public static String nome, cpf_cnpj, telefone, endereco;
public static void menu_principal() { Scanner input = new Scanner(System.in); char opcao1; do { System.out.print("\n ================ BEM VINDO! ================ \n"); System.out.print("\nDigite um dos comandos abaixo para prosseguir:\n\n"); System.out.print(“C - Gerenciar clientes\n”); System.out.print(“T - Gerenciar contas\n”); System.out.print(“S - Sair do programa\n”); System.out.print("\nEscolha: "); opcao1 = input.next().charAt(0);
switch (opcao1) { case 'C': menu_gerenciar_cliente(); break; case 'T': menu_gerenciar_conta(); break; case 'S': break; default: System.out.print("\n** Comando invalido digite C, T ou S para prosseguir **\n"); } } while (opcao1 != 'S'); System.out.print("\nAté mais!\n");
}
public static void menu_gerenciar_cliente() { Scanner input = new Scanner(System.in); char opcao2; do { System.out.print("\n================ GERENCIAR CLIENTES ================\n “); System.out.print(”\nDigite um dos comandos abaixo para prosseguir:\n\n"); System.out.print(“C - Cadastrar um cliente\n”); System.out.print(“L - Listar todos os clientes cadastrados\n”); System.out.print(“B - Buscar cliente ja cadastrado\n”); System.out.print(“A - Atualizar um cliente cadastrado\n”); System.out.print(“E - Excluir um cliente cadastrado\n”); System.out.print(“S - Sair do menu de gerenciamento de clientes\n”); System.out.print("\nEscolha: "); opcao2 = input.next().charAt(0);
switch(opcao2) { case 'C': cadastro_cliente(); break; case 'L': lista_clientes(); break; case 'B': busca_clientes(); break; case 'A': //atualizar_info_cliente(); break; case 'E': //excluir_cliente(); break; case 'S': break; default: System.out.print("\n** Comando invalido digite C, L, B, A, E ou S para prosseguir **\n"); }
}while(opcao2 != ‘S’); System.out.print("\nAté mais!\n"); }
public static void cadastro_cliente() {
Scanner input =new Scanner(System.in);System.out.print("\n================ CADASTRO DE CLIENTE ================\n "); System.out.print("\n"); System.out.print("Digite o nome completo: "); String nome = input.nextLine(); System.out.print("Digite o CPF ou CNPJ: "); String cpf_cnpj = input.nextLine(); System.out.print("Digite o telefone: "); String telefone = input.nextLine(); System.out.print("Digite o endereço: "); String endereco = input.nextLine(); lista_clientes.add(new Clientes(nome,cpf_cnpj,telefone,endereco)); if(lista_clientes.size() == 1) { }else { for(int i = 0; i < lista_clientes.size(); i++) { if(!lista_clientes.get((lista_clientes.size()-1)).getCpf_cnpj().equals(lista_clientes.get(i).getCpf_cnpj())) { }else { if(i == (lista_clientes.size()-1)) { break; }else { System.out.print("\n================ ERRO ================\n"); System.out.print("\nCliente já cadastrado!\n"); lista_clientes.remove((lista_clientes.size()-1)); break; } } } }
}
public static void lista_clientes() { if(lista_clientes.isEmpty()) { System.out.print("\n================ ERRO ================\n"); System.out.print("\nNenhum cliente cadastrado!\n"); }else { System.out.println("\n================ LISTA DE CLIENTES CADASTRADOS ================\n"); for(int i = 0; i < lista_clientes.size(); i++) { System.out.print("Cliente " + (i+1) + “:\n”); System.out.println("Nome: " + lista_clientes.get(i).getNome() + “\t” + "\tCPF/CNPJ: " + lista_clientes.get(i).getCpf_cnpj() + “\t” + "\tTelefone: " + lista_clientes.get(i).getTelefone() + “\t” + "\tEndereço: " + lista_clientes.get(i).getEndereco() + “\t” + "\tCódigo: " + lista_clientes.get(i).getCodigo() + “\n”); } } }
public static void busca_clientes() { Scanner input = new Scanner(System.in); char opcao3; do { System.out.print("\n================ BUSCA DE CLIENTES ==================\n"); System.out.print("\nEscolha como deseja buscar o cliente:\n\n"); System.out.print(“N - Pelo nome\n”); System.out.print(“C - Pelo codigo\n”); System.out.print(“P - Pelo CPF/CNPJ\n”); System.out.print(“S - Sair do menu de busca de clientes\n”); System.out.print("\nEscolha: "); opcao3 = input.next().charAt(0);
switch(opcao3) { case 'N': System.out.print("\nDigite o nome que deseja buscar: "); String nome_busca = input.nextLine(); for(int i = 0; i < lista_clientes.size(); i++) { if(nome_busca.equals(lista_clientes.get(i).getNome())) { System.out.print("\n================ CLIENTE ENCONTRADO ================\n"); System.out.print("\nNome: " + lista_clientes.get(i).getNome() + "\t" + "\tCPF/CNPJ: " + lista_clientes.get(i).getCpf_cnpj() + "\t" + "\tTelefone: " + lista_clientes.get(i).getTelefone() + "\t" + "\tEndereço: " + lista_clientes.get(i).getEndereco() + "\t" + "\tCódigo: " + lista_clientes.get(i).getCodigo() + "\t" + "\n"); break; }else { System.out.print("\n================ ERRO ================\n"); System.out.print("\nCliente não encontrado!"); break; } } break; case 'C': System.out.print("\nDigite o codigo que deseja buscar: "); int codigo_busca = input.nextInt(); for(int i = 0; i < lista_clientes.size(); i++) { if(codigo_busca == lista_clientes.get(i).getCodigo()) { System.out.print("\n================ CLIENTE ENCONTRADO ================\n"); System.out.print("\nNome: " + lista_clientes.get(i).getNome() + "\t" + "\tCPF/CNPJ: " + lista_clientes.get(i).getCpf_cnpj() + "\t" + "\tTelefone: " + lista_clientes.get(i).getTelefone() + "\t" + "\tEndereço: " + lista_clientes.get(i).getEndereco() + "\t" + "\tCódigo: " + lista_clientes.get(i).getCodigo() + "\t" + "\n"); break; }else { System.out.print("\n================ ERRO ================\n"); System.out.print("\nCliente não encontrado!\n"); break; } } break; case 'P': System.out.print("\nDigite o CPF/CNPJ que deseja buscar: "); String cpf_cnpj_busca = input.nextLine(); for(int i = 0; i < lista_clientes.size(); i++) { if(cpf_cnpj_busca.equals(lista_clientes.get(i).getCpf_cnpj())) { System.out.print("\n================ CLIENTE ENCONTRADO ================\n"); System.out.print("\nNome: " + lista_clientes.get(i).getNome() + "\t" + "\tCPF/CNPJ: " + lista_clientes.get(i).getCpf_cnpj() + "\t" + "\tTelefone: " + lista_clientes.get(i).getTelefone() + "\t" + "\tEndereço: " + lista_clientes.get(i).getEndereco() + "\t" + "\tCódigo: " + lista_clientes.get(i).getCodigo() + "\t" + "\n"); break; }else { System.out.print("\n================ ERRO ================\n"); System.out.print("\nCliente não encontrado!"); break; } } break; case 'S': break; default: System.out.print("\n** Comando invalido digite N, C, P ou S para prosseguir **\n"); } }while(opcao3 != 'S'); System.out.print("\nAté mais!\n");
} public static void menu_gerenciar_conta() { Scanner input = new Scanner(System.in); char opcao4; do { System.out.print("\n================ GERENCIAR CONTAS ==================\n"); System.out.print("\nDigite um dos comandos abaixo para prosseguir:\n\n"); System.out.print(“R - Listagem de todas as contas cadastradas\n”); System.out.print(“C - Cadastrar uma conta para um cliente\n”); System.out.print(“L - Listar todas as contas de um cliente\n”); System.out.print(“W - Realizar um saque em uma conta\n”); System.out.print(“D - Realizar um deposito em uma conta\n”); System.out.print(“T - Realizar transferencia entre contas\n”); System.out.print(“E - Exibir extrato de uma conta\n”); System.out.print(“S - Sair do menu de gerenciamento de contas\n”); System.out.print("\nEscolha: "); opcao4 = input.next().charAt(0);
switch(opcao4) { case 'R': //CODIGO PARA LISTAR TODAS AS CONTAS case 'C': //CODIGO PARA CADASTRAR UMA CONTA PARA CLIENTE case 'L': //CODIGO PARA LISTAR TODAS AS CONTAS DE UM CLIENTE case 'W': //CODIGO PARA REALIZAR SAQUE case 'D': //CODIGO PARA REALIZAR DEPOSITO case 'T': //CODIGO PARA REALIZAR TRANSFERENCIA ENTRE CONTAS case 'E': //CODIGO PARA EXIBIR EXTRATO DE UMA CONTA case 'S': break; default: System.out.print("\n** Comando invalido digite R, C, L, W, D, T, E ou S para prosseguir **\n"); }
}while(opcao4 != ‘S’); System.out.print("\nAté mais!\n"); }
public static void main(String[] args) { menu_principal(); }
}