Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. public class Cat {
  2.  
  3. private String name;
  4. private String color;
  5. private String breed;
  6. private double weight;
  7. private int age;
  8. private double feed;
  9.  
  10. public Cat (String name, String color, String breed, double weight, int age){
  11. this.name = name;
  12. this.color = color;
  13. this.breed = breed;
  14. this.weight = weight;
  15. this.age = age;
  16. }
  17. public Cat(){
  18. }
  19.  
  20. public String getName (){
  21. return name;
  22. }
  23. public void setName(String name) {
  24. this.name = name;
  25. }
  26. public String getBreed (){
  27. return breed;
  28. }
  29. public void setBreed(String breed) {
  30. this.breed = breed;
  31. }
  32. public String getColor (){
  33. return color;
  34. }
  35. public void setColor(String color) {
  36. this.color = color;
  37. }
  38. public double getWeight() {
  39. return weight;
  40. }
  41. public void setWeight(double weight) {
  42. this.weight = weight;
  43. }
  44. public int getAge() {
  45. return age;
  46. }
  47. public void setAge(int age) {
  48. this.age = age;
  49. }
  50. public double getFeed() {
  51. return weight*0.8;
  52. }
  53. public void setFeed(double feed) {
  54. this.feed = feed;
  55. }
  56.  
  57. public void printCharacteristics (){
  58. System.out.println("Імя " + name);
  59. System.out.println("Колір " + color);
  60. System.out.println("Порода " + breed);
  61. System.out.println("Вага " + weight + " кг");
  62. System.out.println("Вік " + age + " років");
  63. System.out.format("Потрібно корму на день %.1f кr", + getFeed());
  64. System.out.println();
  65. System.out.println();
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement