What do I need to change in this method to work correctly?

1

This method searches the Customer's phone for the Reservations that are made on it.

The Customer may have more than one reservation, but the method is only showing the first booking registered on the client. What should I change in the code to show all?

public void pesquisaImovelPorCliente(String telefoneCliente)
{
    boolean localizouImovel = false;//variável auxiliar para verificar se a busca teve sucesso

    for(int i = 0; i< qtdeReservas; i++)
    {
        if(ListaDeReservas[i].cliente.getTelefone().equals(telefoneCliente)){

            ListaDeReservas[i].exibeDados();

            //busca teve sucesso-
            localizouImovel = true;

            break;
        }
    }

    if(!localizouImovel)//se não localizou
      System.out.println ("Não foi localizado nenhuma acomodação para este telefone.");
}
    
asked by anonymous 08.06.2017 / 20:15

1 answer

3

This break is causing the flow to exit the for. Delete it!

    
08.06.2017 / 20:18