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 subtract 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. To get the current date, use:

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter16: Graphics
Section: Chapter Questions
Problem 16RQ
icon
Related questions
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 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 subtract 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.

To get the current date, use:

datetime.date.today()

which also has a year attribute.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT