Assignment 5
Using recursion
Submit before 11:30 Saturday February 24

Overview

For this assignment, you will further develop the Employee class so that it tracks which employees supervise other employees. You will then develop a recursive function that displays an organization chart for a list of employees.

Instructions and code writing

  1. Based on the Employee class from lab 2, review this implementation for assignment 5. Add a new instance variable called supervisees to the constructor (__init__). Initialize it to the empty list.
  2. Add a new method called add_supervisee to the Employee class. In addition to the self object, it should take another Employee object as a parameter and assign this second Employee object as a supervisee to the self object.
  3. Complete the function, called add_supervising in the assn5.py file, that takes a list of Employee objects. It then reads the file supervising.txt, which consists of lines, each with 2 IDs, separated by commas. The first ID refers to the supervisor and the second to their supervisee. Use the Employee class method get_employee to look up the Employee object based on the ID. Make the assignment, using the add_supervisee method, for each line.
  4. Write a method called display_structure, which displays the self object and all supervisees that they supervise. This method should include an optional indent parameter, whose default is assigned to the empty string. Each recursive call should add spaces to indent so that supervisees are printed with indentation under their supervisee. Hint: start with a non-recursive print that just shows the top level. Then, see if you can add the recursive call to view the whole employee hierarchy.

Deliverable

Create a text, word or pdf file that contains the following:

  1. A statement that summarizes your completion of the assignment. The statement should include any help you received or whether you discussed your assignment with others. Keep in mind that you may not copy code from others or allow others to copy your code.
  2. Output that shows that your code works
  3. A summary of the files included in the zip folder

Put your doc file and your py files in a folder, zip it, and submit it on D2L. Check that your submitted zip file is complete.

Grading

The assignment is worth 5 points. Full credit will be awarded to complete, accurate and well presented submissions. Points will be deducted for the following:

  • Missing requirements
  • Inaccuracies (possibly excepting minor ones)
  • Poorly written explanations