Commit 4876f0d
committed
Add methods-exercise2.py: refactor Person class to use date_of_birth
- Replace age (int) parameter with date_of_birth (datetime.date)
- Convert is_adult() from free function to instance method
- Implement dynamic age calculation based on current date
- Account for whether birthday has occurred this year
- Add type hints for all parameters and return types
- Include example usage with imran and eliza instances1 parent 01fb96a commit 4876f0d
1 file changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments