Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Operacoes{
- private int valor = 0;
- public void Soma(int valor1, int valor2){
- valor = valor1 + valor2;
- }
- public void Subtrai(int valor1, int valor2){
- valor = valor1 - valor2;
- }
- public void Multiplica(int valor1, int valor2){
- valor = valor1 * valor2;
- }
- public void Divide(int valor1, int valor2) throws ArithmeticException{
- if(valor2 == 0){
- throw new ArithmeticException();
- }else{
- valor = valor1 / valor2;
- }
- }
- public int getValor() throws NegaException{
- if(valor < 0){
- throw new NegaException();
- }
- return valor;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement