A C++ program to build and visualize a hierarchical family tree. This application enables users to interactively add family members, define parent-child relationships, and visualize the family tree structure. It robustly handles scenarios where users attempt to add a family member to a specified parent who may or may not exist within the tree.
- Each individual in the family tree is represented by their name, birthdate, and a list of their children.
- The family tree begins with a single root individual.
- The program should support adding and visualizing multiple generations in the family tree.
- Visualization should use ASCII-based hierarchy representation for clarity.
- The program should provide user-friendly input validation and error messages for invalid operations
- Define the
Individual
class with private attributes for name, birthdate, and a vector of children. Include methods for adding a child, getting the name, birthdate, and children. - Define the
FamilyTree
class with a private attribute for the root individual. Include methods for adding a child, visualizing the family tree, and getting the root. - In the
main
function, create an instance of theFamilyTree
class with a root name and birthdate. - Create a vector of
Individual*
calledindividuals
and add the root individual to it. - Enter a loop to display the main menu and handle user input. Repeat until the user chooses to exit.
- Inside the loop, display the main menu options:
- Add Family Member
- Visualize Family Tree
- Exit
- Prompt the user to enter their choice.
- If the user selects "Add Family Member":
- Prompt the user for the parent's name, child's name, and child's birthdate.
- Search for the parent in the
individuals
vector to find the individual to whom the child will be added. - Create a new
Individual
for the child and add it as a child of the parent. - Add the child to the
individuals
vector. - Display a success message.
- If the user selects "Visualize Family Tree":
- Call the
visualizeTree
method on the root individual to display the family tree hierarchy.
- Call the
- If the user selects "Exit":
- Display a goodbye message.
- Break out of the loop to exit the program.
- If the user enters an invalid choice, display an error message.
- Repeat the loop until the user chooses to exit.
This project is co-owned by: @AmishiDesai04 @chahelgupta Arushi Sangle
Please don't hesitate to offer suggestions, report any issues you encounter, share your feedback, or engage in any other form of communication! Your input is highly valued and appreciated.