Crenox

GoodDog PRogram

Jan 31st, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. package samkough.main;
  2.  
  3. public class GoodDog
  4. {
  5. private int size;
  6.  
  7. public int getSize()
  8. {
  9. return size;
  10. }
  11.  
  12. public void setSize(int s)
  13. {
  14. size = s;
  15. }
  16.  
  17. void bark()
  18. {
  19. if (size > 60)
  20. {
  21. System.out.println("WOOF!");
  22. }
  23. else if (size > 14)
  24. {
  25. System.out.println("RUFF!");
  26. }
  27. else
  28. {
  29. System.out.println("YIP!");
  30. }
  31. }
  32. }
  33. ------------------------------------------------------------------------------------------------------------------
  34. package samkough.main;
  35.  
  36. public class GoodDogTestDrive
  37. {
  38. public static void main(String args[])
  39. {
  40. GoodDog one = new GoodDog();
  41. one.setSize(70);
  42. GoodDog two = new GoodDog();
  43. two.setSize(8);
  44. System.out.println("Dog one: " + one.getSize());
  45. System.out.println("Dog two: " + two.getSize());
  46. one.bark();
  47. two.bark();
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment