Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

Observe the end of the glass tube and note what happens.

Answered: 1 week ago

Question

How would you describe your typical day at work?

Answered: 1 week ago