Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. public void atualizaQuantidade(int[] qtd_retirado){
  2.        
  3.         int[] aux = new int[qtd_retirado.length];
  4.         for(int i=0; i<qtd_retirado.length;i++){
  5.             aux[i] = qtd_retirado[i] - this.getQuantidade(i);
  6.         }
  7.      
  8.         this.setQuantidade(aux);
  9.        
  10.     }
  11.    
  12.    
  13.     public boolean realizaVenda(String dia, String hora, int[] cod, double[] preco, int[] qtdVend, int[] qtd){// passa como paramentro dia, hora, codigo, preco, quantidade vendida e quantidade em estoque dos produtos vendidos
  14.        
  15.         for(int i=0; i< qtdVend.length;i++){
  16.             if(qtdVend[i] > this.getQuantidade(i)) return false; //erro injetado de proposito, deveria ser >=  
  17.           }  
  18.        
  19.      
  20.         this.setHora(hora);
  21.         this.setDia(dia);
  22.         this.setCodigo(cod);
  23.         this.setPreco(preco);
  24.         this.setQtdvendidos(qtdVend);
  25.        
  26.         this.atualizaQuantidade(qtdVend);
  27.        
  28.       return true;
  29.      
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement