Guest User

Untitled

a guest
Jun 22nd, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. package com.yahoo.hlctt;
  2.  
  3. public class Cat {
  4. private String name;
  5. private int age;
  6. private double furriness;
  7. private boolean playfulness;
  8.  
  9. Cat(String name, int age, double furriness, boolean playfulness) {
  10. this.name = name;
  11. this.age = age;
  12. this.furriness = furriness;
  13. this.playfulness = playfulness;
  14. }
  15.  
  16. Cat() {
  17.  
  18. }
  19.  
  20. public String getName() {
  21. return name;
  22. }
  23.  
  24. public void setName(String name) {
  25. this.name = name;
  26. }
  27.  
  28. public int getAge() {
  29. return age;
  30. }
  31.  
  32. public void setAge(int age) {
  33. this.age = age;
  34. }
  35.  
  36. public double getFurriness() {
  37. return furriness;
  38. }
  39.  
  40. public void setFurriness(double furriness) {
  41. this.furriness = furriness;
  42. }
  43.  
  44. public boolean isPlayfulness() {
  45. return playfulness;
  46. }
  47.  
  48. public void setPlayfulness(boolean playfulness) {
  49. this.playfulness = playfulness;
  50. }
  51.  
  52. // Behavior //
  53.  
  54. public void meow() {
  55. if (playfulness) {
  56. System.out.println(name + ": Meow");
  57. }
  58. }
  59.  
  60. public void sleep() {
  61. if (age >= 10 && !playfulness) {
  62. System.out.println(name + ": zZz");
  63. }
  64. }
  65.  
  66. }
Add Comment
Please, Sign In to add comment