Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package task5;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Objects;
- public class Family {
- private Human mother;
- private Human father;
- private static ArrayList<Human> children = new ArrayList<Human>();
- private Pet pet;
- private static int a;
- private int countFamily = 2;
- public Family(Human mother, Human father, Pet pet) {
- this.mother = mother;
- this.father = father;
- this.pet = pet;
- }
- public Family(Human mother, Human father) {
- this.mother = mother;
- this.father = father;
- }
- public Family(Human mother, Human father, ArrayList<Human> children, Pet pet) {
- this.mother = mother;
- this.father = father;
- this.children = children;
- this.pet = pet;
- }
- public Human getMother() {
- return mother;
- }
- public void setMother(Human mother) {
- this.mother = mother;
- }
- public Human getFather() {
- return father;
- }
- public void setFather(Human father) {
- this.father = father;
- }
- public Pet getPet() {
- return pet;
- }
- public void setPet(Pet pet) {
- this.pet = pet;
- }
- public ArrayList<Human> getChildren() {
- return children;
- }
- public void setChildren(ArrayList<Human> children) {
- this.children = children;
- }
- public void addChild(Human human) {
- children = new ArrayList<Human>();
- children.add(human);
- }
- public void deletechild(Human b) {
- children.remove(b);
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Family family = (Family) o;
- return countFamily == family.countFamily &&
- Objects.equals(mother, family.mother) &&
- Objects.equals(father, family.father) &&
- Objects.equals(children, family.children) &&
- Objects.equals(pet, family.pet);
- }
- @Override
- public int hashCode() {
- return Objects.hash(mother, father, children, pet, countFamily);
- }
- @Override
- public String toString() {
- return "Family{" +
- "mother=" + mother +
- ", father=" + father +
- ", children=" + children +
- ", pet=" + pet +
- ", countFamily=" + countFamily +
- '}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement