Question: While using java what would we need to add in order to find the siblings of a specific person? private void processParents(Scanner input) { while

While using java what would we need to add in order to find the siblings of a specific person?

private void processParents(Scanner input) { while (input.hasNextLine()) { String personName = input.nextLine(); String motherName = input.nextLine(); String fatherName = input.nextLine(); Person p = find(personName); if (!motherName.equals("unknown")) { Person mother = find(motherName); p.setMother(mother); mother.addChild(p); } if (!fatherName.equals("unknown")) { Person father = find(fatherName); p.setFather(father); father.addChild(p); }

import java.util.*;

public class Person { private String name; private Person mother; private Person father; private ArrayList children;

public Person(String name) { this.name = name; this.children = new ArrayList(); }

public String getName() { return this.name; }

public Person getMother() { return this.mother; }

public Person getFather() { return this.father; }

public ArrayList getChildren() { return this.children; public void setMother(Person mother) { this.mother = mother; }

public void setFather(Person father) { this.father = father; }

public void addChild(Person child) { this.children.add(child); } }

// WE NEED TO ADD SOMETHING IN ORDER TO FIND THE SIBLINGS OF A PERSON

// i assume we would need to sort the names into a new arraylist just like the children

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!