Advertisement
Guest User

Untitled

a guest
May 25th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public class Animale {
  2.  
  3.  
  4.  
  5. private int peso;
  6.  
  7. public Animale(int peso){
  8. this.peso = peso;
  9. }
  10.  
  11. public int getPeso() {
  12.  
  13. return peso;
  14. }
  15.  
  16. public void setPeso(int peso) throws Exception{
  17.  
  18. if(peso > 0)
  19. this.peso = peso;
  20. else
  21. throw new Exception();
  22. }
  23.  
  24. public void verso(){
  25. System.out.println("mmmmm");
  26. }
  27.  
  28. public String toString(){
  29. return "Animale: "+this.peso;
  30. }
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement