Last active
December 20, 2015 16:28
-
-
Save marciojrtorres/6161173 to your computer and use it in GitHub Desktop.
Parâmetros demais == "malz"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImovelDAO { | |
List<Imovel> busca (Integer nroQuartos, Integer nroVagasCarro, | |
Double vlrMaximoCondominio, Double vlrMaximoAluguel, | |
Boolean comFoto, Boolean apartamento) { | |
// ... código necessário para fazer a busca | |
} | |
} | |
// uma chamada seria assim: | |
ImovelDAO dao = new ImovelDAO(); | |
// o que seriam "2, 2, 800, 500, false, true" sem olhar a assinatura no método? | |
List<Imovel> imoveis = dao.busca(2, 2, 800, 500, false, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImovelDAO { | |
List<Imovel> busca (FiltroImovel filtro) { // só um parâmetro! | |
// ... código necessário para fazer a busca | |
} | |
} | |
// classe,objeto parâmetro | |
class FiltroImovel { | |
public Integer nroQuartos, nroVagasCarro; | |
public Double vlrMaximoCondominio, vlrMaximoAluguel; | |
public Boolean comFoto, apartamento; | |
} | |
// uma chamada seria assim: | |
ImovelDAO dao = new ImovelDAO(); | |
FiltroImovel filtro = new FiltroImovel() {{ | |
vlrMaximoAluguel = 500; | |
nroQuartos = 2; | |
vlrMaximoCondominio = 800; | |
apartamento = true; | |
comFoto = false; | |
nroVagasCarro = 2; | |
}}; | |
List<Imovel> imoveis = dao.busca(filtro); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment