Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. package task5;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.Objects;
  6.  
  7. public class Family {
  8. private Human mother;
  9. private Human father;
  10. private static ArrayList<Human> children = new ArrayList<Human>();
  11. private Pet pet;
  12. private static int a;
  13. private int countFamily = 2;
  14.  
  15. public Family(Human mother, Human father, Pet pet) {
  16. this.mother = mother;
  17. this.father = father;
  18. this.pet = pet;
  19. }
  20.  
  21. public Family(Human mother, Human father) {
  22. this.mother = mother;
  23. this.father = father;
  24. }
  25.  
  26. public Family(Human mother, Human father, ArrayList<Human> children, Pet pet) {
  27. this.mother = mother;
  28. this.father = father;
  29. this.children = children;
  30. this.pet = pet;
  31. }
  32.  
  33. public Human getMother() {
  34. return mother;
  35. }
  36.  
  37. public void setMother(Human mother) {
  38. this.mother = mother;
  39.  
  40. }
  41.  
  42. public Human getFather() {
  43. return father;
  44. }
  45.  
  46. public void setFather(Human father) {
  47. this.father = father;
  48. }
  49.  
  50.  
  51. public Pet getPet() {
  52. return pet;
  53. }
  54.  
  55. public void setPet(Pet pet) {
  56. this.pet = pet;
  57. }
  58.  
  59. public ArrayList<Human> getChildren() {
  60. return children;
  61. }
  62.  
  63. public void setChildren(ArrayList<Human> children) {
  64. this.children = children;
  65. }
  66.  
  67. public void addChild(Human human) {
  68. children = new ArrayList<Human>();
  69. children.add(human);
  70. }
  71.  
  72. public void deletechild(Human b) {
  73.  
  74.  
  75. children.remove(b);
  76.  
  77. }
  78.  
  79.  
  80. @Override
  81. public boolean equals(Object o) {
  82. if (this == o) return true;
  83. if (o == null || getClass() != o.getClass()) return false;
  84. Family family = (Family) o;
  85. return countFamily == family.countFamily &&
  86. Objects.equals(mother, family.mother) &&
  87. Objects.equals(father, family.father) &&
  88. Objects.equals(children, family.children) &&
  89. Objects.equals(pet, family.pet);
  90. }
  91. @Override
  92. public int hashCode() {
  93. return Objects.hash(mother, father, children, pet, countFamily);
  94. }
  95.  
  96. @Override
  97. public String toString() {
  98. return "Family{" +
  99. "mother=" + mother +
  100. ", father=" + father +
  101. ", children=" + children +
  102. ", pet=" + pet +
  103. ", countFamily=" + countFamily +
  104. '}';
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement