diff --git a/app/main.py b/app/main.py index a740cca7..58042292 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,27 @@ +from __future__ import annotations + + class OnlineCourse: - # write your code here - pass + def __init__( + self, + name: str, + description: str, + weeks: int + ) -> None: + self.name = name + self.description = description + self.weeks = weeks + + @classmethod + def from_dict(cls, course_dict: dict) -> OnlineCourse: + return cls( + course_dict.get("name"), + course_dict.get("description"), + OnlineCourse.days_to_weeks(course_dict.get("days")) + ) + + @staticmethod + def days_to_weeks(days: int) -> int: + if days % 7 == 0: + return days // 7 + return (days // 7) + 1