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 Contabil { | |
// relatório de lançamentos não contabilizados | |
void relatorio() { | |
// lançamentos deste ano, desde o início do ano até a data atual | |
List<Lancamento> l1 = lancamentoService.lancamentos( | |
new Date(new Date().getYear(), 1, 1), new Date()); | |
// lançamentos não contabilizados |
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 ClienteDAO { | |
List<Cliente> busca (Double rendaMinima, Double rendaMaxima) { | |
if (rendaMinima != null) // inclui o mínimo na busca | |
else // a renda mínima é ignorada | |
if (rendaMaxima != null) // inclui o máximo na busca | |
else // a renda máxima é ignorada | |
// ... código necessário para fazer a busca |
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: |
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 ClienteDAO { | |
public List<Cliente> buscaPorNome(String nome, String sobrenome) { | |
// ... código necessário para buscar clientes pelo nome e sobrenome | |
} | |
// ... | |
class ClienteDAO { | |
public List<Cliente> buscaPorNome(String nome, String sobrenome) { | |
// ... código necessário para buscar clientes pelo nome e sobrenome | |
} |
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 PedidoService { | |
public Pedido fazPedido(Carrinho carrinho) { | |
// ... instruções iniciais | |
if (carrinho.getFormaPagamento() == CARTAO_CREDITO) { | |
checaCreditoCliente(carrinho.getCliente()); | |
} | |
// ... mais instruções | |
} | |
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 PedidoService { | |
public Pedido fazPedido(Carrinho carrinho) { | |
// checar se o carrinho está vazio | |
if (carrinho.getItens().size() == 0) { | |
throw new IllegalArgumentException("Carrinho Vazio"); | |
} | |
// checar se a forma de pagamento foi selecionada |
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 PedidoService { | |
public Pedido fazPedido(Carrinho carrinho) { | |
if (carrinho.getItens().size() == 0) { | |
throw new IllegalArgumentException("Carrinho Vazio"); | |
} | |
if (carrinho.getFormaPagamento() == null) { | |
throw new IllegalArgumentException( | |
"Forma Pagamento não selecionada"); |
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
// em inglês: | |
class StringUtilities { | |
boolean isNumber(String string) { | |
// ... | |
} | |
} | |
// situação de uso em que parece parte da linguagem: | |
if (StringUtilities.isNumber(var)) { | |
// ... |
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 Cavaleiro extends Personagem { | |
void ataca() { ... } | |
void anda() { ... } | |
// void guarda() { ... } // guarda o quê? | |
void guardaEspada() { ... } // melhor | |
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 Mensagem { | |
void envia() { ... } | |
} | |
class Documento { | |
void imprime() { ... } | |
} | |
// situação de uso: | |
Documento documento = new Documento(); |