+ 1
Is there something in java i can use that will hold multiple strings ?
I have a section in my program where you can set member of the family tree's relations. For example I have the user enter strings like : Jr is a parent of Tre. The problem is i don't know what i can use that will hold Jr's children tre , jay, and dee. And i would also like to have some type of code that will create something new to distinguish when a new parent comes only with different children. This is what i have so far https://code.sololearn.com/cC0N3O84iUgd/#java
5 Answers
+ 2
Ralf Lukner yes that's what I want. I want the user to be able to input Jr parents Tre. And to have something also distinguish that Jane parents James. And have something keep trace of the relation or children.
0
Are you familiar with Arrays or other collections? You might be able to use an array of strings to represent a person's children, like: String[] children = ["child1name", "child2name", "child3name"]
0
You use the s (set) option of your program to set relationships.
0
how about something like this: public class Person implements Comparable<Person>{
public static enum Sex {
MALE,
FEMALE;
}
private int refnr;
private String name;
private Sex sex;
private Date birthdate;
private Date deathdate;
private Person father;
private Person mother;
private Person spouse;
private ArrayList<Person> children;
private ArrayList<Person> exspouses;
0
you create an a propery for the things a person has ... an ArrayList<Person> to store the children