Advertisement
Eduardo_Pires

código atualizado (classe produto)

Oct 15th, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1.  
  2.  
  3. public class Produto {
  4.  
  5.     public String[] nome = new String[100];
  6.     public float[] preco = new float[4];
  7.     public int[] qtd_estoque = new int[4];
  8.  
  9.     public boolean altera_preco(float preco, float porcentagem)
  10.     {
  11.         float temp;
  12.  
  13.         if(porcentagem > -100)
  14.         {
  15.             temp = 1 + porcentagem/100;
  16.             //O this.preco não funciona e sem ele o código roda, porém não troca o preço
  17.             this.preco = preco * temp;
  18.             return true;
  19.         }
  20.         else
  21.         {
  22.             return false;
  23.         }
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement