MP6: Person
Introduction
- You will be adding code to the Person class provided to you in the MP project.
- You should use recursion wherever possible.
- You are not allowed to use any loops. Specifically, you will be writing the following six instance methods:
- count: this instance method takes no parameters. It should return the number (int) of people in the tree (including this person). Note that if the family tree had only a single node, count() would return 1.
- countGender: this instance method takes one parameter, a char denoting the gender we want to count (we will only use 'M' and 'F'). This method should return the number (int) of males or females in the family tree.
- countGrandChildren: this instance method takes no parameters and returns an int. This method should return the number of grandchildren of the current person. Note that the children, great grandchildren... are NOT included. This method counts ONLY the grandchildren of the current person. Be sure to use recursion. Hint: make this method a wrapper to a general recursive method with a depth integer parameter.
- countMaxGenerations: this instance method takes no parameters and counts the number of generations represented by the family tree. The method returns an int. The root counts as the first generation.
- search: this instance method searches for a particular person in the family tree.