Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. public class Cat {
  2. private String name;
  3. private String breed;
  4. private String color;
  5. private int age;
  6. private double weight;
  7.  
  8. public Cat(String name, String breed, String color, int age, double weight) {
  9. this.name = name;
  10. this.breed = breed;
  11. this.color = color;
  12. this.age = age;
  13. this.weight = weight;
  14. }
  15.  
  16. public Cat(String breed, String color, int age, double weight) {
  17. this.breed = breed;
  18. this.color = color;
  19. this.age = age;
  20. this.weight = weight;
  21. }
  22.  
  23. public Cat(String color, int age, double weight) {
  24. this.color = color;
  25. this.age = age;
  26. this.weight = weight;
  27. }
  28.  
  29. public Cat() {
  30. }
  31.  
  32. public String getName() {
  33. return name;
  34. }
  35.  
  36. public String getBreed() {
  37. return breed;
  38. }
  39.  
  40. public String getColor() {
  41. return color;
  42. }
  43.  
  44. public int getAge() {
  45. return age;
  46. }
  47.  
  48. public double getWeight() {
  49. return weight;
  50. }
  51.  
  52. public void setName(String name) {
  53. this.name = name;
  54. }
  55.  
  56. public void setBreed(String breed) {
  57. this.breed = breed;
  58. }
  59.  
  60. public void setColor(String color) {
  61. this.color = color;
  62. }
  63.  
  64. public void setAge(int age) {
  65. this.age = age;
  66. }
  67.  
  68. public void setWeight(double weight) {
  69. this.weight = weight;
  70. }
  71. public void mnyau(){
  72. System.out.println("MNYAU-MNYAU");
  73. }
  74. public void print(){
  75. System.out.println();
  76. if (name == null) {
  77. this.name = "unkown";
  78. }
  79. if (breed == null){
  80. this.breed = "unkown";
  81. }
  82. System.out.println("Name: "+name);
  83. System.out.println("Breed: "+breed);
  84. System.out.println("Color: "+color);
  85. System.out.println("Age cat: "+age);
  86. System.out.println("Weight: "+weight);
  87. }
  88.  
  89. @Override
  90. public String toString() {
  91. return "Cat{" + "name='" + name + '\'' +
  92. ", breed='" + breed + '\'' +
  93. ", color='" + color + '\'' +
  94. ", age=" + age +
  95. ", weight=" + weight +
  96. '}';
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement