Question
In java, I bolded my error in my code, it is in the FTree class and maybe PPerson class (I bolded this one too). Here
In java,
I bolded my error in my code, it is in the FTree class and maybe PPerson class (I bolded this one too).
Here is what the complier said:
error: cannot find symbol boolean relativeFound = PreorderTraversal(p1, personsTraversed, false, false); symbol: variable p1 location: class FTree
FTree class:
import java.util.*; import java.util.ArrayList;
public class FTree { //public data members public ArrayList
ArrayList PPerson class: import java.util.*; import java.util.ArrayList; public class PPerson { //public data member public String Name; public String DOB; public boolean IsMale; public PPerson Mother; public PPerson Father; public ArrayList public void AddParent(PPerson parent, boolean isMother) { if(isMother) { this.Mother = parent; } else { this.Father = parent; } } //add partner to person's partner collection public boolean AddPartner(PPerson partner) { boolean result = false; if(!Partners.contains(partner)) { Partners.add(partner); return true; } if(!partner.Partners.contains(this)) { partner.Partners.add(this); } return result; } //add child to person's children collection public boolean AddChild(PPerson child) { if(!Children.contains(child)) { Children.add(child); return true; } return false; } //display all persons related to this person //perform preorder traversal of family tree starting from current person public void Display() { //perform preorder traversal of family tree starting from current person ArrayList // my teacher wrote, again with a tilde(~) " ArrayList } } Test class: public class Test { public static void main(String[] args) { FTree myFamily = new FTree(); PPerson johnDoe = new PPerson(true, "John Doe", ""); myFamily.Add(johnDoe); PPerson maryJane = new PPerson(false, "Mary Jane", ""); johnDoe.AddPartner(maryJane); maryJane.AddChild(new PPerson(true, "Jim Doe", johnDoe, maryJane)); PPerson jennDoe = new PPerson(false, "Jennifer Doe", johnDoe, maryJane); maryJane.AddChild(jennDoe); PPerson timClark = new PPerson(true, "Tim Clark", ""); jennDoe.AddPartner(timClark); PPerson jessClark = new PPerson(false, "Jesse Clark", timClark, jennDoe); jennDoe.AddChild(jessClark); PPerson nicoleDoe = new PPerson(false, "Nicole Doe", ""); johnDoe.AddPartner(nicoleDoe); PPerson nickJonah = new PPerson(true, "Nick Jonah", ""); nicoleDoe.AddPartner(nickJonah); nicoleDoe.AddChild(new PPerson(false, "Nancy Jonah", nickJonah, nicoleDoe)); johnDoe.Display(); myFamily.FindRelation(nickJonah, jessClark); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started