|
| 1 | +from calendar import month |
| 2 | + |
| 3 | + |
| 4 | +class Collection: |
| 5 | + |
| 6 | + def __init__(self, title, page_start, length=1): |
| 7 | + self.title = title |
| 8 | + self.page_start = page_start |
| 9 | + self.page_end = page_start + length - 1 |
| 10 | + self.item = [] |
| 11 | + |
| 12 | + def __str__(self): |
| 13 | + return self.title |
| 14 | + |
| 15 | + def expand(self, by): |
| 16 | + self.page_end += by |
| 17 | + |
| 18 | + def add_item(self, bullet, note, signifier=None): |
| 19 | + """Adds an item to the monthly log.""" |
| 20 | + |
| 21 | + |
| 22 | +class MonthlyLog(Collection): |
| 23 | + |
| 24 | + def __init__(self, month, year, page_start, length=2): |
| 25 | + super().__init__(f"{month} {year}", page_start, length) |
| 26 | + self.events = [] |
| 27 | + |
| 28 | + def __str__(self): |
| 29 | + return f"{self.title} (Monthly Log)" |
| 30 | + |
| 31 | + def add_event(self, event, date=None): |
| 32 | + """Logs an event for the given date (today by default).""" |
| 33 | + |
| 34 | + |
| 35 | +class FutureLog(Collection): |
| 36 | + |
| 37 | + def __init__(self, start_month, page_start): |
| 38 | + super().__init__("Future Log", page_start, 4) |
| 39 | + self.start = start_month |
| 40 | + self.months = [start_month] # TODO: Add other five months. |
| 41 | + |
| 42 | + def add_item(self, bullet, note, signifier=None, month=None): |
| 43 | + """Adds an item to the future log for the given month.""" |
| 44 | + |
| 45 | + |
| 46 | +log = FutureLog('May 2023', 5) |
| 47 | +log.add_item('June 2023', '.', 'Clean mechanical keyboard') |
| 48 | +print(log) # prints "Future Log" |
| 49 | + |
| 50 | +monthly = MonthlyLog('April', '2023', 9) |
| 51 | +monthly.add_event('Finally learned Python inheritance!') |
| 52 | +monthly.add_item('.', 'Email Ben re: coffee meeting') |
| 53 | +print(monthly) # prints "April 2023 (Monthly Log)" |
| 54 | + |
| 55 | +to_read = Collection("Books to Read", 17) |
| 56 | +to_read.add_item('.', 'Anne of Avonlea') |
| 57 | +print(to_read) # prints "Books to Read" |
0 commit comments