Project in question, described:
Quote
Your fourth project is to write a program to build and display a family tree.
I want you to use a class to hold the needed data for each person and pointers to the people associated
with each person [wife and children].
The input for the people consists of a name (with a trailing distinguishing number; treat the
number as a part of the name), a birthdate, a marital status (either ‘M’ or ‘S’), a wife name
and birthdate if the marital status is ‘M’, a variable number of children names, a possible
death date (which will start with a digit, so you can distinguish it from a child name), and
a trailing ‘X’.
zB:
Steve1 12Nov1931 M Mary1 17Dec1833 Steve2 Harry1 Sue1 3Jan1959 X
Steve2 31Dec1957 S Xavier1 X
After the people, there will be the word ‘QUIT’ and a series of names (possibly a spouse
name).
For each name, I want you to print that person, in parentheses his/her birthdate),
if married the string ” x ” (with the spaces) his/her spouse and their birthdate, and on
succeeding indented lines the children and their birthdates (one per line).
So he mentioned in class about writing a "person" class and then having a tree sort of 'form' within. I didn't really understand that. How I understood it as:
Write a Family Tree class that has data fields for the above info
String Name
String Birthdate
Char MaritalStatus
Children *kids (linked list)
String Deathdate
then I would have the usual tree functions, slightly modified to attain certain ends.
However, I have some glaring issues I need to think through
1: How will I handle the input? Once again, we are being given an EXTERNAL FILE which will be input into the program. AKA, we should use some form of
Code
while (cin << someString)
to handle it. The X obviously delimits between adding nodes to the tree, but I am not sure if I am given a line like he gave for example
Code
Steve1 12Nov1931 M Mary1 17Dec1833 Steve2 Harry1 Sue1 3Jan1959 X
Steve2 31Dec1957 S Xavier1 X
how I would handle that. Like, I could theoretically make like a bunch of temporary data structures to hold the info in the main program then attempt to add them all at once (seems like it would be waaay too annoying for the function definition for treeAdd)
2: Am I even going about this the right way? Does writing a tree as a class make sense?
Anyone, if you got advice, let me know.
This post was edited by Eep on Nov 14 2012 08:48pm