Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void cadastrarVenda (Venda venda) throws VendaJaCadastradaException {
- Produto produto = procurarProduto(venda.getVendido());
- if (produto != null) {
- if (produto.getEstoque() > 0) {
- Funcionario funcionario = (Funcionario)procurarPessoa(venda.getVendedor());
- if (funcionario != null ) {
- Cliente cliente = (Cliente)procurarPessoa(venda.getComprador());
- if (cliente != null) {
- if(cliente.getSaldo() > produto.getPreco()*1.1) {
- cliente.setSaldo(cliente.getSaldo()-(produto.getPreco()*1.1));
- funcionario.receberGorgeta(produto.getPreco()*0.1);
- cliente.setDinheiroGasto(produto.getPreco()*1.1);
- funcionario.atenderMesa();
- produto.retirarEstoque(1);
- this.vendas.cadastrar(venda);
- } else if (cliente.getSaldo() > produto.getPreco()) {
- cliente.setSaldo(cliente.getSaldo()-(produto.getPreco()));
- cliente.setDinheiroGasto(produto.getPreco());
- funcionario.atenderMesa();
- produto.retirarEstoque(1);
- this.vendas.cadastrar(venda);
- } else throw new SaldoInsuficienteException();
- } else throw new PessoaNaoEncontradaException();
- } else throw new PessoaNaoEncontradaException();
- } else throw new EstoqueInsuficienteException();
- } else throw new ProdutoNaoExisteException();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement