|We are keeping a family tree. We update the data by adding information as it
becomes available. When information arrives that is not
consistent with the previous data, we need to recognize that fact immediately.
We will enforce only the most obvious rules:|
Each piece of data gives either the names of a child and parent or the name of a person and that person's gender. All occurrences of a name represent the same person. Create a class FamilyTree that contains a method firstBad that is given a String data. The method returns the (0-based) index of the first element of data that is inconsistent with the previous elements of data, or returns -1 if all the data is consistent.
Each element of data will be formatted in one of these two forms:
"childname parentname" "name gender"where the two parts are separated by a single space character, each name is all uppercase letters 'A'-'Z' and gender is a single lowercase letter, either 'm' or 'f'.
|-||data will contain between 1 and 50 elements, inclusive.|
|-||Each element of data will be formatted as above.|
|-||Each element of data will contain between 3 and 50 characters, inclusive.|