We will now look at at how to represent and manipulate the person data with our own Person class.
Instead of each person being a dictionary, we will represent them with the class that has methods for dealing with the connections. We will restructure our code so that the functions become methods of the class. You may also wish to refer to the course notes on object-oriented design.
One example of the starting point for the structure is the file initial_person_class.py.
We have implemented some methods for these classes, but not everything that is required (the remaining methods have pass instead of actual code).
Fill in the remaining code in initial_person_class.py so that the file works as before.
Run the file to make sure the assertions are still satisfied.
Commit your changes.
Create a pull request from your branch to the original friend-group repository and use the text in the description to link your PR to this issue Answers UCL-MPHY0021-21-22/RSE-Classwork#44
This follows on from #43.
Stage 2: Using a Person Class
We will now look at at how to represent and manipulate the person data with our own Person class.
Instead of each person being a dictionary, we will represent them with the class that has methods for dealing with the connections. We will restructure our code so that the functions become methods of the class. You may also wish to refer to the course notes on object-oriented design.
One example of the starting point for the structure is the file
initial_person_class.py
. We have implemented some methods for these classes, but not everything that is required (the remaining methods havepass
instead of actual code).Your task:
initial_person_class.py
so that the file works as before.Answers UCL-MPHY0021-21-22/RSE-Classwork#44