Question: Implement a person class with the following attributes: Name: String Place of Birth: String Birthdate: Date Gender: String The constructor will receive the name and

Implement a person class with the following attributes: Name: String Place of Birth: String Birthdate: Date Gender: String The constructor will receive the name and birthday date. The gender and the place of birth should be initialized as empty strings. Make the attributes private and create getter and setter methods. Write a _str_method that prints the name and the age of the person (check the testcase for the format). To calculate the age just substract the year of birth to the current year (don't worry about the day/month, it is not an objective of this exercise). A datetime object has a year attribute that is public. For example: Test Result Name: Susan, Age: 31 birth = datetime.datetime (1990, 5, 17) susan = Person("Susan", birth) print(susan) birth = datetime.datetime (1990, 5, 17) Female susan = Person("Susan", birth) UK susan.set_gender("Female") susan.set_place_of_birth("UK") print(susan.get_gender()) print(susan.get_place_of_birth())
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
