Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. {
  2.  
  3. // fields
  4. private String name;
  5. private short amountOfLegs;
  6. private String favoriteFood;
  7. private String sound;
  8.  
  9. //properties
  10. //getter method
  11. public short getAmountOfLegs()
  12. {
  13. return this.amountOfLegs;
  14. }
  15. //setter method
  16. public void setAmountOfLegs(short amountOfLegs)
  17. {
  18. this.amountOfLegs = amountOfLegs;
  19. }
  20.  
  21. public String getFavoriteFood()
  22. {
  23. return this.favoriteFood;
  24. }
  25. public void setFavoriteFood(String favoriteFood)
  26. {
  27. this.favoriteFood = favoriteFood;
  28. }
  29. public String getSound()
  30. {
  31. return this.sound;
  32. }
  33. public void setSound(String sound)
  34. {
  35. this.sound = sound;
  36. }
  37.  
  38. //constructor
  39. public Zoogdier()
  40. {
  41. this.amountOfLegs = 4;
  42. this.favoriteFood = "Banaan";
  43. this.sound = "OehOehAah";
  44. }
  45. public Zoogdier(short amountOfLegs, String favoriteFood, String sound)
  46. {
  47. this.amountOfLegs = amountOfLegs;
  48. this.favoriteFood = favoriteFood;
  49. this.sound = sound;
  50. }
  51.  
  52. //methods
  53. public void(show)()
  54. {
  55. System.out.println("\r\n+++++++++++++++++++++++++++++++++++++++++++++++" +
  56. "Het aantal benen van dit dier bedraagt: " +this.amountOfLegs + "\r\n" +
  57. "Het lievelingeten van dit dier is: " +this.favoriteFood + "\r\n" +
  58. "Het Geluid van dit die is: " + this.sound + "\r\n" +
  59. "+++++++++++++++++++++++++++++++++++++++++++++");
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement