Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public class Operacoes{
  2.  
  3. private int valor = 0;
  4.  
  5. public void Soma(int valor1, int valor2){
  6. valor = valor1 + valor2;
  7. }
  8.  
  9. public void Subtrai(int valor1, int valor2){
  10. valor = valor1 - valor2;
  11. }
  12.  
  13. public void Multiplica(int valor1, int valor2){
  14. valor = valor1 * valor2;
  15. }
  16.  
  17. public void Divide(int valor1, int valor2) throws ArithmeticException{
  18. if(valor2 == 0){
  19. throw new ArithmeticException();
  20. }else{
  21. valor = valor1 / valor2;
  22. }
  23. }
  24.  
  25. public int getValor() throws NegaException{
  26. if(valor < 0){
  27. throw new NegaException();
  28. }
  29. return valor;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement